Kaynağa Gözat

上传文件至 ''

沐清风 5 yıl önce
ebeveyn
işleme
e9af77629a
4 değiştirilmiş dosya ile 2454 ekleme ve 0 silme
  1. 441 0
      GoodsController.java
  2. 891 0
      GoodsService.java
  3. 193 0
      OrderController.java
  4. 929 0
      OrderService.java

+ 441 - 0
GoodsController.java

@@ -0,0 +1,441 @@
+package com.shop.controller;
+import com.shop.annotation.IsLogin;
+import com.shop.base.BaseController;
+import com.shop.constant.Constant;
+import com.shop.constant.MessageModel;
+import com.shop.gto.GoodsDto;
+import com.shop.model.*;
+import com.shop.service.GoodsService;
+import com.shop.util.MessageModelUtil;
+import com.shop.vo.LoginIdentity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import javax.servlet.http.HttpSession;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 后台登录.....
+ *商家后台登录
+ * @author DY
+ * @create 2018-03-06 12:03
+ **/
+@RestController
+@RequestMapping("goods")
+public class GoodsController extends BaseController {
+
+    @Autowired
+    private GoodsService goodsService;
+    /**
+     *@author DY
+     *@create 2018/3/26 17:28
+     *test
+     */
+    @RequestMapping("test")
+    public MessageModel test(Goods goods) throws Exception {
+         goodsService.insertSize( goods);
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    /**
+     *@author DY
+     *@create 2018/3/26 17:28
+     *根据选择属性查询商品
+     */
+    @IsLogin
+    @RequestMapping("query_goods_by_attribute")
+    public MessageModel query_goods_by_attribute(String size,String color,Boolean isCustom,Integer goods) throws Exception {
+        MessageModel messageModel = goodsService.query_goods_by_attribute(size,color,isCustom,goods);
+        return messageModel;
+    }
+
+
+    /**
+     *@author DY
+     *@create 2018/3/26 17:28
+     *查询尺码详情表(用于自定义添加下拉框选择)
+     */
+    @IsLogin
+    @RequestMapping("query_size")
+    public MessageModel query_size_add() throws Exception {
+        MessageModel messageModel=goodsService.query_size_add();
+        return messageModel;
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/26 17:28
+    *查询可定制项
+    */
+    @IsLogin
+    @RequestMapping("query_custom_names")
+    public MessageModel query_custom_names() throws Exception {
+        MessageModel messageModel = goodsService.query_custom_names();
+        return messageModel;
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/26 17:28
+    *查询场合
+    */
+    @IsLogin
+    @RequestMapping("query_product_scene")
+    public MessageModel query_product_scene(Integer gender) throws Exception {
+        MessageModel messageModel=goodsService.query_product_scene( gender);
+        return messageModel;
+    }
+    /**
+    *@author DY
+    *@create 2018/3/26 17:28
+    *查询二级分类(根据男女)
+    */
+    @IsLogin
+    @RequestMapping("query_product_category_one")
+    public MessageModel query_product_category(Integer gender) throws Exception {
+        MessageModel messageModel=goodsService.query_product_category( gender);
+        return messageModel;
+    }
+
+    /**
+     *@author DY
+     *@create 2018/3/26 17:28
+     *查询三级分类(根据二级目录)
+     */
+    @IsLogin
+    @RequestMapping("query_product_category_two")
+    public MessageModel query_product_category_two(Integer categoryId) throws Exception {
+        MessageModel messageModel=goodsService.query_product_category_two( categoryId);
+        return messageModel;
+    }
+
+
+
+
+    /**
+     *@author DY
+     *@create 2018/3/26 17:28
+     *查询尺码详情表(根据三级目录)
+     */
+    @IsLogin
+    @RequestMapping("query_size_by_three")
+    public MessageModel query_size(Integer categoryIdChildren) throws Exception {
+        MessageModel messageModel=goodsService.query_size( categoryIdChildren);
+        return messageModel;
+    }
+
+
+    /**
+    *@author DY
+    *@create 2018/3/6 12:07
+    *添加商品
+    */
+    @IsLogin
+    @RequestMapping("add_goods")
+    public MessageModel add_goods(Goods goods, HttpSession session) throws Exception {
+        LoginIdentity loginIdentity = (LoginIdentity)session.getAttribute(Constant.LOGIN_USER_KEY);
+        MessageModel messageModel=goodsService.add_goods(goods,loginIdentity);
+        return messageModel;
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/21 10:43
+    *商品总览接口
+    */
+    @IsLogin
+    @RequestMapping("goods_overview")
+    public MessageModel goods_overview(HttpSession session) throws Exception {
+        LoginIdentity loginIdentity = (LoginIdentity) session.getAttribute(Constant.LOGIN_USER_KEY);
+        Map map=goodsService.goods_overview (loginIdentity);
+        MessageModel messageModel=MessageModelUtil.getSuccessMessageModel(map);
+        return messageModel;
+    }
+
+    /**
+     *@author DY
+     *@create 2018/3/21 10:43
+     *商品列表接口
+     */
+    @IsLogin
+    @RequestMapping("goods_list_product")
+    public MessageModel goods_list(GoodsDto goodsDto, HttpSession session) throws Exception {
+        LoginIdentity loginIdentity = (LoginIdentity)session.getAttribute(Constant.LOGIN_USER_KEY);
+        MessageModel messageModel=goodsService.goods_list(goodsDto,loginIdentity);
+        return messageModel;
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/23 11:34
+    *查看商品审核详情
+    */
+    @IsLogin
+    @RequestMapping("query_goods_check_status")
+    public MessageModel query_goods_check_status(Integer id) throws Exception {
+        MessageModel messageModel=goodsService.query_goods_check_status(id);
+        return messageModel;
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/23 12:05
+    *查看商品详情
+    */
+    @IsLogin
+    @RequestMapping("query_goods_detail")
+    public MessageModel query_goods_detail(Integer id) throws Exception {
+        Map map=goodsService.query_goods_detail(id);
+        MessageModel messageModel= MessageModelUtil.getSuccessMessageModel(map);
+        return messageModel;
+    }
+
+
+    /**
+    *@author DY
+    *@create 2018/3/23 12:05
+    *查看商品库存
+    */
+    @IsLogin
+    @RequestMapping("query_goods_stock")
+    public MessageModel query_goods_stock(Integer id) throws Exception {
+        List<ProductNoCustom> map=goodsService.query_goods_stock(id);
+        MessageModel messageModel= MessageModelUtil.getSuccessMessageModel(map);
+        return messageModel;
+    }
+
+
+    /**
+    *@author DY
+    *@create 2018/3/23 12:05
+    *查看具体商品详情
+    */
+    @IsLogin
+    @RequestMapping("query_product_detail")
+    public MessageModel query_product_detail(Integer id) throws Exception {
+        MessageModel messageModel= goodsService.query_product_detail(id);;
+        return messageModel;
+    }
+
+
+    /**
+    *@author DY
+    *@create 2018/3/26 17:37
+    *商品集体上下架,设置为新品/推荐
+    */
+    @IsLogin
+    @RequestMapping("is_marketable_is_new_product_recommend")
+    public MessageModel is_marketable_is_new_product_recommend(IsMarketableNewRecommend isMarketableNewRecommend) throws Exception {
+        MessageModel messageModel=goodsService.is_marketable_is_new_product_recommend(isMarketableNewRecommend);
+        return messageModel;
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/26 18:34
+    *货品编辑
+    */
+    @IsLogin
+    @RequestMapping("edit_product")
+    public MessageModel edit_product(Goods goods) throws Exception {
+        MessageModel messageModel=goodsService.edit_product(goods);
+        return messageModel;
+    }
+
+
+    /**
+    *@author DY
+    *@create 2018/3/26 18:34
+    *货品编辑_修改默认商品
+    */
+    @IsLogin
+    @RequestMapping("edit_default_product")
+    public MessageModel edit_default_product(Integer id,String defaultGoods) throws Exception {
+        MessageModel messageModel=goodsService.edit_default_product(id,defaultGoods);
+        return messageModel;
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/27 16:06
+    *货品删除
+    */
+    @IsLogin
+    @RequestMapping("delete_goods")
+    public MessageModel delete_goods(String ids) throws Exception {
+        MessageModel messageModel=goodsService.delete_goods(ids);
+        return messageModel;
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/27 16:06
+    *商品添加
+    */
+    @IsLogin
+    @RequestMapping("add_product")
+    public MessageModel add_product(String product) throws Exception {
+        MessageModel messageModel=goodsService.add_product(product);
+        return messageModel;
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/27 16:06
+    *商品修改
+    */
+    @IsLogin
+    @RequestMapping("update_product")
+    public MessageModel update_product(UpdateProduct product) throws Exception {
+        MessageModel messageModel=goodsService.update_product(product);
+        return messageModel;
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/27 16:06
+    *商品删除
+    */
+    @IsLogin
+    @RequestMapping("delete_product")
+    public MessageModel delete_product(String ids) throws Exception {
+        MessageModel messageModel=goodsService.delete_product(ids);
+        return messageModel;
+    }
+
+    /**
+     *@author DY
+     *@create 2018/3/27 16:06
+     *细节定制商品添加
+     */
+    @IsLogin
+    @RequestMapping("add_product_custom")
+    public MessageModel add_product_custom(String customProduct) throws Exception {
+        MessageModel messageModel=goodsService.add_product_custom(customProduct);
+        return messageModel;
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/27 16:06
+    *细节定制商品修改
+    */
+    @IsLogin
+    @RequestMapping("update_product_custom")
+    public MessageModel update_product_custom(ProductCustom productCustom) throws Exception {
+        MessageModel messageModel=goodsService.update_product_custom(productCustom);
+        return messageModel;
+    }
+    /**
+    *@author DY
+    *@create 2018/3/27 16:06
+    *细节定制商品删除
+    */
+    @IsLogin
+    @RequestMapping("delete_product_custom")
+    public MessageModel delete_product_custom(String ids) throws Exception {
+        MessageModel messageModel=goodsService.delete_product_custom(ids);
+        return messageModel;
+    }
+
+
+    /**
+     *@author DY
+     *@create 2018/3/27 16:06
+     *商品搜索-商品列表
+     */
+    @IsLogin
+    @RequestMapping("search_goods_list")
+    public MessageModel search_goods_list(GoodsDto goodsDto,HttpSession session) throws Exception {
+        LoginIdentity loginIdentity = (LoginIdentity)session.getAttribute(Constant.LOGIN_USER_KEY);
+        MessageModel messageModel=goodsService.search_goods_list(goodsDto,loginIdentity);
+        return messageModel;
+    }
+
+    /**
+     *@author DY
+     *@create 2018/3/27 16:06
+     *查看商品回收站
+     */
+    @IsLogin
+    @RequestMapping("goods_recycle_list")
+    public MessageModel goods_recycle_list( GoodsDto goodsDto,HttpSession session) throws Exception {
+        LoginIdentity loginIdentity = (LoginIdentity)session.getAttribute(Constant.LOGIN_USER_KEY);
+        MessageModel messageModel=goodsService.goods_recycle_list(goodsDto,loginIdentity);
+        return messageModel;
+    }
+
+    /**
+     *@author DY
+     *@create 2018/3/27 16:06
+     *商品回收站-还原-删除
+     * 1.还原  2.删除
+     */
+    @IsLogin
+    @RequestMapping("goods_recycle_return")
+    public MessageModel goods_recycle_return(String ids,Integer returnOrDelete) throws Exception {
+        MessageModel messageModel= goodsService.goods_recycle_return(ids,returnOrDelete);
+        return messageModel;
+    }
+
+    /**
+     *@author DY
+     *@create 2018/3/27 16:06
+     *商品属性列表
+     */
+    @IsLogin
+    @RequestMapping("goods_attribute_list")
+    public MessageModel goods_attribute_list(Integer orderItemId) throws Exception {
+        MessageModel messageModel=goodsService.getGoodsAttribute(orderItemId);
+        return messageModel;
+    }
+
+    /**
+     *@author DY
+     *@create 2018/3/27 16:06
+     *商品尺码添加 --- goods, size , productCategory 所属子品类
+     */
+    @IsLogin
+    @RequestMapping("add_size")
+    public MessageModel add_size(Goods goods) throws Exception {
+        MessageModel messageModel=goodsService.add_size(goods);
+        return messageModel;
+    }
+    /**
+     *@author DY
+     *@create 2018/3/27 16:06
+     *商品尺码更新
+     */
+    @IsLogin
+    @RequestMapping("update_size")
+    public MessageModel update_size(SizeReturn size) throws Exception {
+        MessageModel messageModel=goodsService.update_size(size);
+        return messageModel;
+    }
+    /**
+     *@author DY
+     *@create 2018/3/27 16:06
+     *商品尺码添加
+     */
+    @IsLogin
+    @RequestMapping("delete_size")
+    public MessageModel delete_size(Integer id) throws Exception {
+        MessageModel messageModel=goodsService.delete_size(id);
+        return messageModel;
+    }
+
+    /**
+     *@author DY
+     *@create 2018/3/27 16:06
+     *商品属性切换--删除
+     */
+    @IsLogin
+    @RequestMapping("goods_product_delete")
+    public MessageModel goods_product_delete(Integer goods,Boolean isCustom) throws Exception {
+        MessageModel messageModel=goodsService.goods_product_delete(goods,isCustom);
+        return messageModel;
+    }
+
+
+}

+ 891 - 0
GoodsService.java

@@ -0,0 +1,891 @@
+package com.shop.service;
+
+import com.alibaba.fastjson.JSON;
+import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
+import com.github.miemiedev.mybatis.paginator.domain.PageList;
+import com.github.miemiedev.mybatis.paginator.domain.Paginator;
+import com.shop.constant.DmConstant;
+import com.shop.constant.MessageModel;
+import com.shop.dao.GoodsDao;
+import com.shop.dao.OrderDao;
+import com.shop.dao.ProductDao;
+import com.shop.exception.ParamException;
+import com.shop.gto.GoodsDto;
+import com.shop.model.*;
+import com.shop.util.AssertUtil;
+import com.shop.util.MessageModelUtil;
+import com.shop.util.ProductAttributeUtil;
+import com.shop.vo.LoginIdentity;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import java.math.BigDecimal;
+import java.util.*;
+
+/**
+ * @author DY
+ * @create 2018-03-16 16:03
+ **/
+@Service
+@Transactional
+public class GoodsService {
+
+    @Autowired
+    private GoodsDao goodsDao;
+
+    @Autowired
+    private ProductDao productDao;
+
+    @Autowired
+    private OrderDao orderDao;
+
+
+    public MessageModel  add_goods(Goods goods, LoginIdentity loginIdentity) {
+        MessageModel messageModel = new MessageModel();
+        //查询设计师名称和id根据store
+        //goods.setBrandDesignerId(loginIdentity.getBrandDesignerId());
+        //goods.setBrandDesigner(loginIdentity.getBrandDesigner());
+        goods.setStore(loginIdentity.getStore());
+        goods.setSortSynthesize(BigDecimal.ZERO);
+        //参数验证
+        checkParams(goods);
+        if(goods.getIsCustom()==1||goods.getIsCustom()==2){
+            AssertUtil.isNotEmpty(goods.getDefaultChose(),"请上传基款");
+        }
+        //查询商品是否存在
+        Integer cod = goodsDao.findGoodsIsExistByGoodsSn(goods.getGoodsSn(),loginIdentity.getStore());
+        AssertUtil.isTrue(cod != null, "货品已存在...");
+        goods.setType(loginIdentity.getType());
+        goods.setSales(BigDecimal.ZERO);
+        goods.setHits(BigDecimal.ZERO);
+        goods.setVersion(DmConstant.VERSION_ZERO);
+        goods.setIsMarketable(false);
+        goods.setIsTop(false);
+        goods.setIsNew(false);
+        goods.setIsRecommend(false);
+        //排序设为0  默认按时间排序
+        goods.setSort(DmConstant.CREATE_TIME);
+        //判断此商品是否支持定制
+        Integer isCustom = goods.getIsCustom();
+        if(goods.getFreight()==null){
+            goods.setFreight(BigDecimal.ZERO);
+        }
+        //先插入商品库得到商品ID
+        goodsDao.insert(goods);
+        Integer goodsId = goods.getId();
+        //插入尺寸表
+        insertSize(goods);
+        //套 码 类
+        if (isCustom == 0) {
+            insertProduct(goods, goodsId);
+        }
+        else{
+
+            //定制+套码(1.纯定制商品属性(必有) 2.套码定制属性(必传) 3.细节定制属性(选传))
+            //纯定制
+            if (isCustom == 2) {
+                insertProduct(goods, goodsId);
+            }
+
+            //定制属性
+            insertCustomerProduct(goods.getCustomProduct(), goodsId);
+            //插入细节定制表
+            insertProductCustomer(goods, goodsId);
+
+        }
+
+
+        return messageModel;
+    }
+
+    private void insertCustomerProduct(String product, Integer goodsId) {
+        List<ProductNoCustom> customProducts = null;
+        //格式化商品大字段
+        AssertUtil.isNotEmpty(product,"请传入定制属性");
+        if (StringUtils.isNotBlank(product)) {
+            customProducts = JSON.parseArray(product, ProductNoCustom.class
+            );
+            //遍历循环插入goodsId
+            for (int i = 0; i < customProducts.size(); i++) {
+                ProductNoCustom customProduct = customProducts.get(i);
+                customProduct.setGoods(goodsId);
+                customProduct.setAllocatedStock(0);
+                customProduct.setIsCustom(true);
+            }
+            //循环插入数据库
+            Integer insertCode = productDao.insertProductNoCustom(customProducts);
+            AssertUtil.intIsNotEmpty(insertCode, "定制1商品插入失败,请联系客服...");
+
+        }
+    }
+
+
+    private void insertProductCustomer(Goods goods, Integer goodsId) {
+        List<ProductCustom> productCustoms = null;
+        //格式化商品大字段
+        String product = goods.getProductCustom();
+        if (StringUtils.isNotBlank(product)) {
+            productCustoms = JSON.parseArray(product, ProductCustom.class
+            );
+            //遍历循环插入goodsId
+            for (int i = 0; i < productCustoms.size(); i++) {
+                ProductCustom productCustom = productCustoms.get(i);
+                productCustom.setGoods(goodsId);
+            }
+            //循环插入数据库
+            Integer insertCode = productDao.insertProductCustom(productCustoms);
+            AssertUtil.intIsNotEmpty(insertCode, "商品插入失败,请联系客服...");
+
+        }
+    }
+
+    private void insertProduct(Goods goods, Integer goodsId) {
+        List<ProductNoCustom> productNoCustoms = null;
+        //格式化商品大字段
+        String product = goods.getProductNoCustom();
+        AssertUtil.isNotEmpty(product, "请传入套码商品");
+        if (StringUtils.isNotBlank(product)) {
+            productNoCustoms = JSON.parseArray(product, ProductNoCustom.class);}
+        //遍历循环插入goodsId
+        for (int i = 0; i < productNoCustoms.size(); i++) {
+            ProductNoCustom productNoCustom = productNoCustoms.get(i);
+            productNoCustom.setIsCustom(false);
+            productNoCustom.setGoods(goodsId);
+            productNoCustom.setAllocatedStock(0);
+        }
+        //循环插入数据库
+        Integer insertCode = productDao.insertProductNoCustom(productNoCustoms);
+        AssertUtil.intIsNotEmpty(insertCode, "商品插入失败,请联系客服...");
+    }
+
+    public void insertSize(Goods goods) {
+        List<Size> sizes = null;
+        Integer goodsId=goods.getId();
+        Integer categoryId=goods.getProductCategory();
+        String size=goods.getSize();
+        AssertUtil.intIsNotEmpty(goodsId,"请选择商品");
+        AssertUtil.intIsNotEmpty(categoryId,"请选择商品");
+        AssertUtil.isNotEmpty(size, "请传入尺寸");
+
+        //查询上下限
+        //SizeClose sizeClose=productDao.findUpAndLowByCategory(categoryId);
+        if (StringUtils.isNotBlank(size)) {
+            sizes = JSON.parseArray(size, Size.class);}
+                //遍历循环插入goodsId
+        for (int i = 0; i < sizes.size(); i++) {
+            Size size1 = sizes.get(i);
+            size1.setGender(goods.getGender());
+            size1.setGoods(goodsId);
+            /*if(!size1.getBackRise().equals(BigDecimal.ZERO)){
+                size1.setBackRiseBig(size1.getBackRise().add(sizeClose.getBackRiseUp()));
+                size1.setBackRiseSmall(size1.getBackRise().subtract(sizeClose.getBackRiseLow()));
+            }
+
+            if(!size1.getClothesLength().equals(BigDecimal.ZERO)){
+                size1.setClothesBig(size1.getClothesLength().add(sizeClose.getClothesUp()));
+                size1.setClothesSmall(size1.getClothesLength().subtract(sizeClose.getClothesLow()));
+            }
+
+            if(!size1.getShoulder().equals(BigDecimal.ZERO)){
+                size1.setShoulderBig(size1.getShoulder().add(sizeClose.getShoulderUp()));
+                size1.setShoulderSmall(size1.getShoulder().subtract(sizeClose.getShoulderLow()));
+            }
+
+            if(!size1.getBust().equals(BigDecimal.ZERO)){
+                size1.setBustBig(size1.getBust().add(sizeClose.getBustUp()));
+                size1.setBustSmall(size1.getBust().subtract(sizeClose.getBustLow()));
+            }
+
+            if(!size1.getSleeve().equals(BigDecimal.ZERO)){
+                size1.setSleeveBig(size1.getSleeve().add(sizeClose.getSleeveUp()));
+                size1.setSleeveSmall(size1.getSleeve().subtract(sizeClose.getSleeveLow()));
+            }
+
+            if(!size1.getWaistline().equals(BigDecimal.ZERO)){
+                size1.setWaistlineBig(size1.getWaistline().add(sizeClose.getWaistlineUp()));
+                size1.setWaistlineSmall(size1.getWaistline().subtract(sizeClose.getWaistlineLow()));
+            }
+
+            if(!size1.getHipline().equals(BigDecimal.ZERO)){
+                size1.setHiplineBig(size1.getHipline().add(sizeClose.getHiplineUp()));
+                size1.setHiplineSmall(size1.getHipline().subtract(sizeClose.getHiplineLow()));
+            }
+
+            if(!size1.getOutside().equals(BigDecimal.ZERO)){
+                size1.setOutsideBig(size1.getOutside().add(sizeClose.getOutsideUp()));
+                size1.setOutsideSmall(size1.getOutside().subtract(sizeClose.getOutsideLow()));
+            }
+
+            if(!size1.getFoot().equals(BigDecimal.ZERO)){
+                size1.setFootBig(size1.getFoot().add(sizeClose.getFootUp()));
+                size1.setFootSmall(size1.getFoot().subtract(sizeClose.getFootLow()));
+            }
+
+            if(!size1.getSweep().equals(BigDecimal.ZERO)){
+                size1.setSweepBig(size1.getSweep().add(sizeClose.getSweepUp()));
+                size1.setSweepSmall(size1.getSweep().subtract(sizeClose.getSweepLow()));
+            }
+
+            if(!size1.getFrontRise().equals(BigDecimal.ZERO)){
+                size1.setFrontRiseBig(size1.getFrontRise().add(sizeClose.getFrontRiseUp()));
+                size1.setFrontRiseSmall(size1.getFrontRise().subtract(sizeClose.getFrontRiseLow()));
+            }
+
+            if(!size1.getCup().equals(BigDecimal.ZERO)){
+                size1.setCupBig(size1.getCup().add(sizeClose.getCupUp()));
+                size1.setCupSmall(size1.getCup().subtract(sizeClose.getCupLow()));
+            }
+
+            if(!size1.getSkirtLength().equals(BigDecimal.ZERO)){
+                size1.setSkirtBig(size1.getSkirtLength().add(sizeClose.getSkirtUp()));
+                size1.setSkirtSmall(size1.getSkirtLength().subtract(sizeClose.getSkirtLow()));
+            }
+            if(!size1.getHip().equals(BigDecimal.ZERO)){
+                size1.setHipBig(size1.getHip().add(sizeClose.getHipUp()));
+                size1.setHipSmall(size1.getHip().subtract(sizeClose.getHipLow()));
+            }
+*/
+
+        }
+        //循环插入数据库
+        Integer insertCode = productDao.insertSize(sizes);
+        AssertUtil.intIsNotEmpty(insertCode, "商品尺码插入失败,请联系客服...");
+    }
+
+
+
+
+    private void checkParams(Goods goods) {
+        AssertUtil.isNotEmpty(goods.getBrandDesigner(),"请添加品牌");
+        AssertUtil.intIsNotEmpty(goods.getBrandDesignerId(),"请添加品牌");
+        AssertUtil.isNotEmpty(goods.getBrandDesigner(), "请填写品牌设计师名称");
+        AssertUtil.intIsNotEmpty(goods.getGender(), "请选择一级分类");
+        AssertUtil.intIsNotEmpty(goods.getCategoryParent(), "请选择二级分类");
+        AssertUtil.intIsNotEmpty(goods.getProductCategory(), "请选择三级分类");
+        AssertUtil.isNotEmpty(goods.getProductSeason(), "请选择季节级分类");
+        AssertUtil.isNotEmpty(goods.getName(), "请填写商品名称");
+        AssertUtil.isNotEmpty(goods.getMemo(), "请填写商品注意事项...");
+        AssertUtil.isNotEmpty(goods.getGoodsSn(), "请填写商品编号");
+        AssertUtil.notNull(goods.getPrice(), "请填写商品价格...");
+        AssertUtil.isNotEmpty(goods.getMaterialDetail(), "请填写材质详情...");
+        AssertUtil.isNotEmpty(goods.getKeyword(), "请填写关键字...");
+        AssertUtil.isNotEmpty(goods.getProductIntroduction(), "请填写商品介绍...");
+        AssertUtil.isNotEmpty(goods.getImage(), "请上传商品主图");
+        AssertUtil.isNotEmpty(goods.getProductImageTop(), "请上传商品副图");
+        AssertUtil.isNotEmpty(goods.getProductImageBottom(), "请上传商品详情图");
+        AssertUtil.isNotEmpty(goods.getServiceProvide(), "请选择商品服务保障");
+        AssertUtil.isNotEmpty(goods.getDeliveryTime(), "请选择商品发货时间");
+        AssertUtil.notNull(goods.getIsCustom(), "请选择是否支持定制");
+        AssertUtil.isNotEmpty(goods.getSize(), "请填写商品尺寸表");
+        AssertUtil.isTrue(goods.getProductCustom() == null && goods.getProductNoCustom() == null, "请上传商品明细");
+    }
+
+
+    /**
+     * @author DY
+     * @create 2018/3/21 16:08
+     * 商品总览
+     */
+    public Map goods_overview(LoginIdentity loginIdentity) {
+        Map map = new HashMap();
+        Integer store = loginIdentity.getStore();
+        Integer type = loginIdentity.getType();
+        //查到上架和已下架,库存紧张.通过审核,未通过审核商品和全部商品
+        Integer version = DmConstant.VERSION_MINUS_TWO;
+        CountGoods countGoods = productDao.queryIsMarketableProduct(store, type, version);
+        AssertUtil.notNull(countGoods,"空空如也...");
+        Integer totalProduct = 0;
+        Integer up = 0;
+        Integer down = 0;
+        Integer stock = 0;
+        Integer unPassToCheck = 0;
+        Integer waitToCheck = 0;
+        Integer passToCheck = 0;
+        if (countGoods.getTotal() != null) {
+            totalProduct = countGoods.getTotal();
+        }
+        map.put("totalProduct", totalProduct);
+        if (countGoods.getUp() != null) {
+            up = countGoods.getUp();
+        }
+        map.put("up", up);
+        if (countGoods.getDown() != null) {
+            down = countGoods.getDown();
+        }
+        map.put("down", down);
+
+        if (countGoods.getUnPassToCheck() != null) {
+            unPassToCheck = countGoods.getUnPassToCheck();
+        }
+        map.put("unPassToCheck", unPassToCheck);
+
+        if (countGoods.getWaitToCheck() != null) {
+            waitToCheck = countGoods.getWaitToCheck();
+        }
+        map.put("waitToCheck", waitToCheck);
+
+        if (countGoods.getPassToCheck() != null) {
+            passToCheck = countGoods.getPassToCheck();
+        }
+        map.put("passToCheck", passToCheck);
+        //拿到库存紧张的商品数量
+        Integer isCustom=0;
+        Integer isMarketable=1;
+        Integer versionStock=1;
+        List<Integer> stockIsLittle = productDao.findProductIsLockStock(store,isCustom, isMarketable,versionStock,type, DmConstant.PRODUCT_STOCK);
+        if (stockIsLittle.size()!= 0) {
+            stock = stockIsLittle.size();
+        }
+        map.put("stock", stock);
+
+        return map;
+    }
+
+
+    public MessageModel goods_list(GoodsDto goodsDto, LoginIdentity loginIdentity) {
+        //拿到全部商品 已上架 未上架 待审核 未通过
+        Map map = goods_overview(loginIdentity);
+        Map mapGetFromUtil = getGoodsList(goodsDto, loginIdentity);
+        map.putAll(mapGetFromUtil);
+        MessageModel messageModel = MessageModelUtil.getSuccessMessageModel(map);
+        return messageModel;
+    }
+
+    private Map getGoodsList(GoodsDto goodsDto, LoginIdentity loginIdentity) {
+        Integer store = loginIdentity.getStore();
+        Integer type = loginIdentity.getType();
+        goodsDto.setStore(store);
+        goodsDto.setType(type);
+
+        //拿到库存紧张的商品数量
+        Integer isCustom=0;
+        Integer isMarketable=1;
+        Integer versionStock=1;
+        List<Integer> ids=productDao.findProductIsLockStock(store,isCustom, isMarketable,versionStock,type, DmConstant.PRODUCT_STOCK);
+
+        String str="";
+        for(int i=0;i<ids.size();i++){
+
+            str += ids.get(i)+",";
+        }
+        if(ids.size()!=0){
+            str = str.substring(0,str.length() - 1);
+        }
+        //判断是否查询库存紧张
+        if(goodsDto.getStock()!=null){
+            goodsDto.setStockIds(str);
+        }
+
+        // 構建pageBounds
+        PageBounds pageBounds = goodsDto.buildPageBounds();
+        List<Goods> goods = goodsDao.queryGoodsList(goodsDto, pageBounds);
+        //把库存紧张的货品置为紧张
+        for (int i = 0; i < goods.size(); i++) {
+            Goods g=goods.get(i);
+            Integer goodsId=g.getId();
+            for(int j=0;j<ids.size();j++){
+                Integer stockId=ids.get(j);
+                if(goodsId.equals(stockId)){
+                    g.setIsStock(true);
+                    break;
+                }
+                else{
+                    g.setIsStock(false);
+                }
+            }
+
+        }
+        // 構建返回結果
+        PageList<Goods> goodsPageList = (PageList<Goods>) goods;
+        Paginator paginator = goodsPageList.getPaginator();
+        Map map = new HashMap();
+        map.put("goods_list", goodsPageList);
+        map.put("paginator", paginator);
+        return map;
+    }
+
+
+    public MessageModel query_goods_check_status(Integer id) {
+        AssertUtil.intIsNotEmpty(id, "请选择要查看的商品");
+        CheckInformation checkInformation = goodsDao.queryGoodsStatusCheck(id);
+        AssertUtil.notNull(checkInformation, "商品不存在,请联系客服...");
+        MessageModel messageModel = MessageModelUtil.getSuccessMessageModel(checkInformation);
+        return messageModel;
+    }
+
+
+    /**
+     * @author DY
+     * @create 2018/3/26 17:30
+     * 查询可定制类目
+     */
+    public MessageModel query_custom_names() {
+        List<CustomName> customNames = goodsDao.queryCustomNames();
+        AssertUtil.listIsNotEmpty(customNames,"查询失败,请联系官方客服....");
+        return MessageModelUtil.getSuccessMessageModel(customNames);
+    }
+
+    public MessageModel is_marketable_is_new_product_recommend(IsMarketableNewRecommend isMarketableNewRecommend) {
+        //参数验证
+        checkParams(isMarketableNewRecommend);
+        Integer code = goodsDao.updateIsMarketableIsNewIsRecommendByIds(isMarketableNewRecommend);
+        AssertUtil.intIsNotEmpty(code, "更新条件失败,请联系客服...");
+        return MessageModelUtil.getSuccessMessageModel();
+
+    }
+
+    private void checkParams(IsMarketableNewRecommend isMarketableNewRecommend) {
+
+        AssertUtil.isNotEmpty(isMarketableNewRecommend.getIds(), "清传入商品ids");
+        //根据name来确定执行的步骤 null全部执行,1.上架.2.新品.3.推荐
+        AssertUtil.isTrue(isMarketableNewRecommend.getIsMarketable() == null && isMarketableNewRecommend.getIsNew() == null && isMarketableNewRecommend.getIsRecommend() == null, "请选择要执行的操作项...提交");
+    }
+
+    /**
+     * @author DY
+     * @create 2018/3/23 12:06
+     * 查看商品详情...
+     */
+    public Map query_goods_detail(Integer id) {
+        Map map = new HashMap();
+        AssertUtil.intIsNotEmpty(id,"请传入货品Id");
+        //拿到货品
+        Goods goods = goodsDao.findProductById(id);
+        AssertUtil.notNull(goods, "货品不存在,请稍后重试...");
+        // 格式化商品图片大字段
+        List<ProductImageTop> productImageListTop = null;
+        String productImagesTop = goods.getProductImageTop();
+        if (StringUtils.isNotBlank(productImagesTop)) {
+            productImageListTop = JSON.parseArray(productImagesTop, ProductImageTop.class);
+            goods.setProductImageTop(null);
+        }
+
+        // 格式化商品图片大字段
+        List<ProductImageBottom> productImageListBottom = null;
+        String productImagesBottom = goods.getProductImageBottom();
+        if (StringUtils.isNotBlank(productImagesBottom)) {
+            productImageListBottom = JSON.parseArray(productImagesBottom, ProductImageBottom.class
+            );
+            goods.setProductImageBottom(null);
+        }
+
+        //查询具体商品信息,判断是否定制
+        Integer isCustom = goods.getIsCustom();
+        List<ProductNoCustom> products = goodsDao.queryProductsByGoodsId(id, DmConstant.CUSTOM_ZERO);
+        //AssertUtil.listIsNotEmpty(products,"查询数据失败,请联系客服...");
+        //套码类,只查product表
+        if (isCustom == 0) {
+            if (products.size() != 0) {
+                products = getProductImage(products);
+                map.put("products", products);
+            }
+        } else {
+            //定制类查product和custom表
+            List<ProductCustom> productCustoms = goodsDao.queryCustomProductsByGoodsId(id);
+            List<ProductNoCustom> customProducts = goodsDao.queryProductsByGoodsId(id, DmConstant.CUSTOM_ONE);
+            if(productCustoms.size()!=0){
+                List<List<ProductCustom>> lists=getCustomList(productCustoms);
+                map.put("productCustoms", lists);
+            }
+            if (customProducts.size() != 0) {
+                customProducts = getSize(customProducts);
+                map.put("customProducts", customProducts);
+            }
+            if (products.size() != 0) {
+                products = getProductImage(products);
+                map.put("products", products);
+            }
+
+            // 格式化默认商品大字段
+            List<DefaultClothes> defaultClothesList = null;
+            String  clothes= goods.getDefaultChose();
+            if (StringUtils.isNotBlank(clothes)) {
+                defaultClothesList = JSON.parseArray(clothes, DefaultClothes.class
+
+                );
+                map.put("defaultClothesList", defaultClothesList);
+            }
+
+
+        }
+
+        //查询尺码表
+        List<SizeReturn> sizeList=goodsDao.findSizeByGoodsId(id);
+
+        map.put("sizeList", sizeList);
+        map.put("goods", goods);
+        map.put("productImageListTop", productImageListTop);
+        map.put("productImageListBottom", productImageListBottom);
+        return map;
+    }
+
+    private List<List<ProductCustom>> getCustomList(List<ProductCustom> productCustoms) {
+
+        Map<Integer, List> map = new LinkedHashMap();
+
+        for (int i = 0; i < productCustoms.size(); i++) {
+            ProductCustom item = productCustoms.get(i);
+            //格式化图片大字段
+            // 格式化商品图片大字段
+            List<CustomImage> customImages = null;
+            String image = item.getImage();
+            if (StringUtils.isNotBlank(image)) {
+                customImages = JSON.parseArray(image, CustomImage.class
+                );
+            }
+            item.setImageList(customImages);
+            Integer key = item.getCustom();
+            //当且仅当集合里有过 1//1才会进这个集合,第一次也不会进,第二次才会进
+            if (map.containsKey(key)) {
+                map.get(key).add(item);
+            } else {
+                List list = new ArrayList();
+                list.add(item);
+                map.put(key, list);
+                System.out.println();
+            }
+
+        }
+
+        List<List<ProductCustom>> data = new PageList<>();
+        for (Map.Entry<Integer, List> entry : map.entrySet()) {
+            data.add(entry.getValue());
+        }
+
+        return data;
+
+    }
+
+    private List<ProductCustom> getProductCustomImage(List<ProductCustom> productCustoms) {
+
+
+        for (int i = 0; i < productCustoms.size(); i++) {
+            ProductCustom item = productCustoms.get(i);
+
+            //格式化图片大字段
+            // 格式化商品图片大字段
+            List<CustomImage> customImages = null;
+            String image = item.getImage();
+            if (StringUtils.isNotBlank(image)) {
+                customImages = JSON.parseArray(image, CustomImage.class
+                );
+            }
+            item.setImageList(customImages);
+        }
+        return productCustoms;
+
+    }
+
+    private List<ProductNoCustom> getProductImage(List<ProductNoCustom> product) {
+
+
+        for (int i = 0; i < product.size(); i++) {
+            ProductNoCustom item = product.get(i);
+            //格式化图片大字段
+            // 格式化商品图片大字段
+            List<CustomImage> customImages = null;
+            String image = item.getImages();
+            if (StringUtils.isNotBlank(image)) {
+                customImages = JSON.parseArray(image, CustomImage.class
+                );
+            }
+            item.setImageList(customImages);
+            item.setImages(null);
+
+        }
+        return product;
+
+    }
+
+    private List<ProductNoCustom> getSize(List<ProductNoCustom> customProducts) {
+
+        for (int i = 0; i < customProducts.size(); i++) {
+            ProductNoCustom item = customProducts.get(i);
+            //格式化图片大字段
+            List<CustomImage> customImages = null;
+            String image = item.getImages();
+            if (StringUtils.isNotBlank(image)) {
+                customImages = JSON.parseArray(image, CustomImage.class
+                );
+                item.setImages(null);
+            }
+            item.setImageList(customImages);
+            item.setImages(null);
+            // 格式化商品图片大字段
+            String size = item.getSize();
+            String[] arr = size.split(",");
+            List<String> customSizeList = Arrays.asList(arr);
+            item.setSizeList(customSizeList);
+        }
+
+        return customProducts;
+
+    }
+
+
+    public MessageModel query_product_scene(Integer gender) {
+        AssertUtil.intIsNotEmpty(gender, "请选择性别...");
+        List<ProductScene> productSceneList = goodsDao.queryProductScene(gender);
+        AssertUtil.listIsNotEmpty(productSceneList,"查询数据失败,请联系客服...");
+        return MessageModelUtil.getSuccessMessageModel(productSceneList);
+    }
+
+    public MessageModel query_product_category(Integer gender) {
+        AssertUtil.intIsNotEmpty(gender, "请选择性别...");
+        List<ProductCategory> productCategoryList = goodsDao.query_product_category(gender);
+        AssertUtil.listIsNotEmpty(productCategoryList,"查询数据失败,请联系客服...");
+        return MessageModelUtil.getSuccessMessageModel(productCategoryList);
+    }
+
+    public MessageModel query_product_category_two(Integer categoryId) {
+        AssertUtil.intIsNotEmpty(categoryId, "请选择分类属性...");
+        List<ProductCategory> productCategoryList = goodsDao.query_product_category_two(categoryId);
+        AssertUtil.listIsNotEmpty(productCategoryList,"查询数据失败,请联系客服...");
+        return MessageModelUtil.getSuccessMessageModel(productCategoryList);
+    }
+
+
+    public MessageModel query_size(Integer categoryIdChildren) {
+        AssertUtil.intIsNotEmpty(categoryIdChildren, "请选择分类属性...");
+        String ids=goodsDao.querySize(categoryIdChildren);
+        List<ProductCategory> productCategoryList = goodsDao.queryClothesNameBySize(ids);
+        AssertUtil.listIsNotEmpty(productCategoryList,"查询数据失败,请联系客服...");
+        return MessageModelUtil.getSuccessMessageModel(productCategoryList);
+    }
+
+    public MessageModel edit_product(Goods goods) {
+        //更新货品
+        AssertUtil.intIsNotEmpty(goods.getId(), "请选择要编辑的商品...");
+        AssertUtil.notNull(goods.getIsCustom(),"请选择尺码是否定制");
+        Integer updateCode = goodsDao.updateGoodsByGoods(goods);
+        AssertUtil.intIsNotEmpty(updateCode, "商品编辑失败...");
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+
+
+
+    public MessageModel delete_goods(String ids) {
+        AssertUtil.isNotEmpty(ids, "请选择要删除的商品");
+        Integer version = DmConstant.VERSION_MINUS_TWO;
+        //删除货品 version置为-2,当且只有version=1时才能删除
+        Integer goodsCode = goodsDao.updateGoodsStatusByIds(ids, version);
+        AssertUtil.intIsNotEmpty(goodsCode, "删除货品失败,请联系客服...");
+        //删除商品
+        productDao.updateProductStatusByGoods(ids, version);
+        //定制的话删除定制类明細及尺码表
+        productDao.updateCustomStatusByGoods(ids, version);
+        productDao.updateSizeByIds(ids,version);
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    public MessageModel search_goods_list(GoodsDto goodsDto, LoginIdentity loginIdentity) {
+        Map map = getGoodsList(goodsDto, loginIdentity);
+        return MessageModelUtil.getSuccessMessageModel(map);
+    }
+
+    public MessageModel goods_recycle_list(GoodsDto goodsDto, LoginIdentity loginIdentity) {
+        goodsDto.setVersion(DmConstant.VERSION_MINUS_TWO);
+        Map map = getGoodsList(goodsDto, loginIdentity);
+        return MessageModelUtil.getSuccessMessageModel(map);
+    }
+
+    public MessageModel goods_recycle_return(String ids, Integer returnOrDelete) {
+        AssertUtil.isNotEmpty(ids, "请选择商品");
+        AssertUtil.intIsNotEmpty(returnOrDelete, "请选择还原还是删除...");
+        Integer version = null;
+        if (returnOrDelete == 1) {
+            version = DmConstant.VERSION_ONE;
+        } else {
+            version = DmConstant.VERSION_MINUS_THREE;
+        }
+        Integer goodsCode = goodsDao.updateGoodsStatusByIds(ids, version);
+        AssertUtil.intIsNotEmpty(goodsCode, "删除货品失败,请联系客服...");
+        productDao.updateProductStatusByGoods(ids, version);
+        productDao.updateCustomStatusByGoods(ids, version);
+        productDao.updateSizeByIds(ids,version);
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+
+    public MessageModel getGoodsAttribute(Integer orderItemId) {
+
+        AssertUtil.notNull(orderItemId, "请选择 子订单ID...");
+        //拿到订单信息
+        OrderItemDetail orderItemDetail = orderDao.findOrderItemById(orderItemId);
+        Boolean isCustom=orderItemDetail.getIsCustom();
+        AssertUtil.notNull(orderItemDetail, "参数有误,订单不存在,请检查参数");
+        Integer goodsId = orderItemDetail.getGoods();
+        Map map = new HashMap();
+        List<AttributeDetail> ls = null;
+        List<ProductNoCustom> customProducts = goodsDao.queryProductsByGoodsId(goodsId, orderItemDetail.getIsCustom());
+        if (customProducts.size() != 0) {
+            //对具体属性去重
+            if(isCustom){
+                ls = ProductAttributeUtil.getCustomProductAttribute(customProducts);
+            }
+            else{
+                ls = ProductAttributeUtil.getProductAttribute(customProducts);
+            }
+            map.put("customProducts", ls);
+        }
+
+        //定制
+        if (isCustom) {
+            List<ProductCustom> productCustoms = goodsDao.findCustomsByGoodsId(goodsId);
+            if (productCustoms.size() != 0) {
+                //对图片进行处理
+                List<List<ProductCustom>> lists = getCustomList(productCustoms);
+                map.put("productCustoms", lists);
+            }
+
+        }
+            return MessageModelUtil.getSuccessMessageModel(map);
+        }
+
+    public MessageModel query_goods_by_attribute(String size,String color,Boolean isCustom,Integer goods) {
+        AssertUtil.notNull(isCustom,"请传入是否定制");
+        AssertUtil.isNotEmpty(size,"请选择商品尺寸");
+        AssertUtil.isNotEmpty(color,"请选择商品颜色");
+       AssertUtil.intIsNotEmpty(goods,"请选择货品goods");
+        if(isCustom){
+            size=null;
+        }
+        Product p=new Product();
+        p.setGoods(goods);
+        p.setSize(size);
+        p.setColor(color);
+        p.setIsCustom(isCustom);
+        Product product=productDao.findProductByAttribute(p);
+        AssertUtil.notNull(product,"选择的商品不存在...");
+        return MessageModelUtil.getSuccessMessageModel(product);
+    }
+
+    public MessageModel delete_product(String ids) {
+        AssertUtil.isNotEmpty(ids,"请选择要删除的商品");
+        Integer code=productDao.deleteProductByIds(ids);
+        AssertUtil.intIsNotEmpty(code,"删除商品失败");
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    public MessageModel delete_product_custom(String ids) {
+        AssertUtil.isNotEmpty(ids,"请选择要删除的商品");
+        Integer code=productDao.deleteCustomByIds(ids);
+        AssertUtil.intIsNotEmpty(code,"删除细节定制失败");
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    public MessageModel update_product(UpdateProduct product) {
+        AssertUtil.notNull(product,"请选择要修改的商品");
+        Integer code=productDao.updateProduct(product);
+        AssertUtil.intIsNotEmpty(code,"商品修改失败");
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    public MessageModel update_product_custom(ProductCustom productCustom) {
+        AssertUtil.notNull(productCustom,"请选择要修改的商品");
+        Integer code=productDao.updateProductCustom(productCustom);
+        AssertUtil.intIsNotEmpty(code,"商品修改失败");
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    public MessageModel add_product(String product) {
+        //格式化商品大字段
+        AssertUtil.isNotEmpty(product,"请传入商品属性");
+        List<ProductNoCustom> products = null;
+        if (StringUtils.isNotBlank(product)) {
+            products = JSON.parseArray(product, ProductNoCustom.class
+            );
+            //循环插入数据库
+            Integer insertCode = productDao.insertProductNoCustom(products);
+            AssertUtil.intIsNotEmpty(insertCode, "定制1商品插入失败,请联系客服...");
+
+        }
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    public MessageModel add_product_custom(String product) {
+        List<ProductCustom> productCustoms = null;
+        //格式化商品大字段
+        if (StringUtils.isNotBlank(product)) {
+            productCustoms = JSON.parseArray(product, ProductCustom.class
+            );
+            //循环插入数据库
+            Integer insertCode = productDao.insertProductCustom(productCustoms);
+            AssertUtil.intIsNotEmpty(insertCode, "商品插入失败,请联系客服...");
+
+        }
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    public MessageModel goods_product_delete(Integer goods, Boolean isCustom) {
+        AssertUtil.intIsNotEmpty(goods,"请选择货品Id");
+        AssertUtil.notNull(isCustom,"请选择商品属性");
+        Integer code=productDao.deleteProductByGoods(goods,isCustom);
+        AssertUtil.intIsNotEmpty(code,"删除失败...");
+        if(isCustom){
+            productDao.deleteCustomByGoods(goods);
+            productDao.deleteDefaultChose(goods,null);
+        }
+
+      return MessageModelUtil.getSuccessMessageModel();
+    }
+
+
+    public MessageModel query_size_add() {
+        List<ProductCategory> productCategoryList = goodsDao.queryAllClothesNameBySize();
+        AssertUtil.listIsNotEmpty(productCategoryList,"查询数据失败,请联系客服...");
+        return MessageModelUtil.getSuccessMessageModel(productCategoryList);
+    }
+
+    public MessageModel add_size(Goods goods) {
+        insertSize(goods);
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    public MessageModel update_size(SizeReturn size) {
+        AssertUtil.intIsNotEmpty(size.getId(),"请选择待修改的记录");
+        Integer code=goodsDao.update_size(size);
+        AssertUtil.intIsNotEmpty(code,"修改记录失败...");
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    public MessageModel delete_size(Integer id) {
+        AssertUtil.intIsNotEmpty(id,"请选择删除记录...");
+        Integer code=goodsDao.delete_size(id);
+        AssertUtil.intIsNotEmpty(code,"删除记录失败...");
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    public MessageModel edit_default_product(Integer id, String defaultGoods) {
+        AssertUtil.intIsNotEmpty(id,"请选择修改的货品id");
+        AssertUtil.isNotEmpty(defaultGoods,"请传入要修改的默认商品");
+        Integer code=goodsDao.updateDefaultGoodsByGoodsId(id,defaultGoods);
+        AssertUtil.intIsNotEmpty(code,"修改失败");
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    public MessageModel query_product_detail(Integer id) {
+        AssertUtil.intIsNotEmpty(id,"请传入货品Id");
+        Map map = new HashMap();
+        List<ProductNoCustom> products = goodsDao.queryProductsByGoodsId(id, DmConstant.CUSTOM_ZERO);
+        AssertUtil.listIsNotEmpty(products,"查询数据失败,请联系客服...");
+        //套码类,只查product表
+            if (products.size() != 0) {
+                products = getProductImage(products);
+            }
+
+            return MessageModelUtil.getSuccessMessageModel(products);
+
+    }
+
+    public List<ProductNoCustom> query_goods_stock(Integer id) {
+        AssertUtil.intIsNotEmpty(id,"请传入货品Id");
+        List<ProductNoCustom> products = goodsDao.queryProductsByGoodsId(id, DmConstant.CUSTOM_ZERO);
+        AssertUtil.listIsNotEmpty(products,"查询数据失败,请联系客服...");
+
+        return products;
+    }
+}
+

+ 193 - 0
OrderController.java

@@ -0,0 +1,193 @@
+package com.shop.controller;
+import com.shop.annotation.IsLogin;
+import com.shop.base.BaseController;
+import com.shop.constant.Constant;
+import com.shop.constant.MessageModel;
+import com.shop.gto.OrderDto;
+import com.shop.model.DeliveryCode;
+import com.shop.model.ProductUpdate;
+import com.shop.model.ReceiveAddress;
+import com.shop.service.OrderService;
+import com.shop.util.MessageModelUtil;
+import com.shop.vo.LoginIdentity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+import javax.servlet.http.HttpSession;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * 后台登录.....
+ *商家后台登录
+ * @author DY
+ * @create 2018-03-06 12:03
+ **/
+@RestController
+@RequestMapping("order")
+public class OrderController extends BaseController {
+
+    @Autowired
+    private OrderService orderService;
+
+
+    /**
+    *@author DY
+    *@create 2018/3/13 18:20
+    *订单总数,销售总额,昨日销售总额,近七天销售总额接口接口
+    */
+    @IsLogin
+    @RequestMapping("order_total_amount")
+    public MessageModel order_total_amount(HttpSession session) throws Exception {
+        LoginIdentity loginIdentity = (LoginIdentity)session.getAttribute(Constant.LOGIN_USER_KEY);
+        MessageModel messageModel=orderService.order_total_amount(loginIdentity);
+        return messageModel;
+    }
+
+
+    /**
+     *@author DY
+     *@create 2018/3/13 18:20
+     *统计待付款,待发货,已发货,已完成(这里的订单总数不包含退款订单  即实际订单总数=这里的totalCount+退款订单总数)
+     */
+    @IsLogin
+    @RequestMapping("query_order_status")
+    public MessageModel query_order_status(HttpSession session) throws Exception {
+        LoginIdentity loginIdentity = (LoginIdentity)session.getAttribute(Constant.LOGIN_USER_KEY);
+
+        MessageModel messageModel=orderService.query_order_status(loginIdentity);
+        return messageModel;
+    }
+
+    /**
+     *@author DY
+     *@create 2018/3/13 18:20
+     *统计确认退款退货申请
+     */
+    @IsLogin
+    @RequestMapping("query_order_refund_status")
+    public MessageModel query_order_refund_status(HttpSession session) throws Exception {
+        LoginIdentity loginIdentity = (LoginIdentity)session.getAttribute(Constant.LOGIN_USER_KEY);
+        Integer refundCount=orderService.query_order_refund_status(loginIdentity);
+        return MessageModelUtil.getSuccessMessageModel(refundCount);
+    }
+
+    /**
+     *@author DY
+     *@create 2018/1/8 18:16
+     *查看订单状态
+     * */
+    @IsLogin
+    @RequestMapping("showObligationOrder")
+    public MessageModel showObligationOrder(OrderDto orderDto,HttpSession session) throws Exception {
+        LoginIdentity loginIdentity = (LoginIdentity)session.getAttribute(Constant.LOGIN_USER_KEY);
+        MessageModel messageModel = orderService.showObligationOrder(orderDto,loginIdentity);
+        return messageModel;
+    }
+
+
+    /**
+     *@author DY
+     *@create 2018/1/8 18:16
+     *查看订单详情-  - 修改收货地址
+     * 传入父订单ID
+     * */
+    @IsLogin
+    @RequestMapping("update_receive_address")
+    public MessageModel update_receive_address(ReceiveAddress receiveAddress) throws Exception {
+       orderService.update_receive_address(receiveAddress);
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    /**
+     *@author DY
+     *@create 2018/1/8 18:16
+     *查看订单详情--修改订单属性,数量
+     * 传入父订单ID(待修改....)
+     * */
+    @RequestMapping("update_order_property")
+    @IsLogin
+    public MessageModel update_order_property(ProductUpdate productUpdate) throws Exception {
+        MessageModel messageModel = orderService.update_order_property(productUpdate);
+        return messageModel;
+    }
+
+    /**
+     *@author DY
+     *@create 2018/1/8 18:16
+     *查看订单详情--修改订单总价
+     * 传入父订单ID
+     * */
+    @RequestMapping("update_order_totalPrice")
+    @IsLogin
+    public MessageModel update_order_totalPrice(BigDecimal totalPrice,Integer orderId) throws Exception {
+        orderService.update_order_totalPrice(totalPrice,orderId);
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    /**
+     *@author DY
+     *@create 2018/3/29 16:30
+     *查询快递公司编码号
+     */
+    @IsLogin
+    @RequestMapping("query_delivery_code")
+    public MessageModel query_delivery_code() throws Exception {
+        List<DeliveryCode> deliveryCodes=orderService.query_delivery_code();
+        return MessageModelUtil.getSuccessMessageModel(deliveryCodes);
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/29 16:30
+    *批量发货
+    */
+    @IsLogin
+    @RequestMapping("send_goods_all")
+    public MessageModel getOrderTracesByJson(String deliverySend) throws Exception {
+        orderService.updateOrderStatusToSend(deliverySend);
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/29 17:53
+    *处理退款申请
+     * orderItemId:子订单Id,isAgree是否同意,refundCodeF:refundCode值
+    */
+    @IsLogin
+    @RequestMapping("deal_with_return_order")
+    public MessageModel deal_with_return_order(Integer orderItemId,Boolean isAgree,Integer refundCodeF) throws Exception {
+        orderService.deal_with_return_order(orderItemId,isAgree,refundCodeF);
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/29 17:53
+    *处理退款申请--确认打款
+     * orderId:父订单id, orderItemId:子订单Id,isAgree:1 同意  2拒绝
+    */
+    @IsLogin
+    @RequestMapping("return_order_to_last")
+    public MessageModel return_order_to_last(Integer orderId,Integer orderItemId,Integer isAgree) throws Exception {
+        orderService.return_order_to_last(orderId,orderItemId,isAgree);
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    /**
+    *@author DY
+    *@create 2018/3/29 17:53
+    *处理退款申请任务
+    */
+    @IsLogin
+    @RequestMapping("task")
+    public void task() throws Exception {
+        orderService.updateOrderStatusToAgree();
+    }
+
+
+
+
+}

+ 929 - 0
OrderService.java

@@ -0,0 +1,929 @@
+package com.shop.service;/**
+ * Created by 17173 on 2018/3/13.
+ */
+
+import com.alibaba.fastjson.JSON;
+import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
+import com.github.miemiedev.mybatis.paginator.domain.PageList;
+import com.github.miemiedev.mybatis.paginator.domain.Paginator;
+import com.shop.constant.DmConstant;
+import com.shop.constant.MessageModel;
+import com.shop.dao.OrderDao;
+import com.shop.dao.ProductDao;
+import com.shop.exception.ParamException;
+import com.shop.gto.IndexDto;
+import com.shop.gto.OrderDto;
+import com.shop.model.*;
+import com.shop.util.AssertUtil;
+import com.shop.util.MessageModelUtil;
+import com.shop.vo.LoginIdentity;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+/**
+ * @author DY
+ * @create 2018-03-13 18:20
+ **/
+@Service
+@Transactional
+public class OrderService {
+
+    @Autowired
+    private OrderDao orderDao;
+    @Autowired
+    private ProductDao productDao;
+
+    /**
+     * @author DY
+     * @create 2018/3/13 19:43
+     * 订单总数,销售总额,昨日销售总额,近七天销售总额接口接口
+     */
+    public MessageModel order_total_amount(LoginIdentity loginIdentity) {
+        MessageModel messageModel = new MessageModel();
+        Map map = new HashMap();
+        OrderDto orderDto = getOrderDto(loginIdentity, DmConstant.VERSION_ONE);
+        //拿到今日订单总数和订单总额
+        orderDto.setTime(0);
+        IndexDto indexDto = orderDao.queryOrderCountAmountTotalByUserId(orderDto);
+        map.put("orderTotalCount", indexDto.getOrderTotalCount());
+        map.put("orderTotalPriceToday", indexDto.getOrderTotalPrice());
+        //拿到昨日销售总额
+        orderDto.setTime(1);
+        indexDto = orderDao.queryOrderCountAmountTotalByUserId(orderDto);
+        map.put("orderTotalPriceYesterday", indexDto.getOrderTotalPrice());
+        //拿到近7天销售总额
+        orderDto.setTime(7);
+        indexDto = orderDao.queryOrderAmountTotalByUserId(orderDto);
+        BigDecimal totalPriceAweek = indexDto.getOrderTotalPrice();
+        map.put("orderTotalPriceAweek", totalPriceAweek);
+        messageModel.setCode(DmConstant.OPS_SUCCESS_CODE);
+        messageModel.setMsg(DmConstant.OPS_SUCCESS_MSG);
+        messageModel.setData(map);
+        return messageModel;
+
+    }
+
+    private OrderDto getOrderDto(LoginIdentity loginIdentity, Integer version) {
+        Integer store = loginIdentity.getStore();
+        Integer type = loginIdentity.getType();
+        OrderDto orderDto = new OrderDto();
+        orderDto.setStore(store);
+        orderDto.setVersion(version);
+        orderDto.setType(type);
+        return orderDto;
+
+    }
+
+    private OrderDto getOrderDto(OrderDto orderDto, LoginIdentity loginIdentity) {
+        Integer store = loginIdentity.getStore();
+        Integer type = loginIdentity.getType();
+        orderDto.setStore(store);
+        orderDto.setType(type);
+        return orderDto;
+    }
+
+    /**
+     * @author DY
+     * @create 2018/3/14 17:08
+     * 统计各个订单状态数量
+     */
+    public MessageModel query_order_status(LoginIdentity loginIdentity) {
+        MessageModel messageModel = new MessageModel();
+        Map map = new HashMap();
+        OrderDto orderDto = getOrderDto(loginIdentity, null);
+        //查询订单个数以status分组统计
+        List<OrderStatus> orders = orderDao.query_order_status(orderDto);
+        AssertUtil.listIsNotEmpty(orders, "你还没订单哦...");
+        Integer total_order = 0;
+        Integer un_pay_order = 0;
+        Integer have_pay_order = 0;
+        Integer wait_receive_order = 0;
+        Integer wait_show_order = 0;
+        Integer have_show_order = 0;
+        Integer close_order = 0;
+        Integer refund_order = 0;
+        Integer refund_order_over = 0;
+
+        for (int i = 0; i < orders.size(); i++) {
+            OrderStatus orderStatus = orders.get(i);
+            total_order += orderStatus.getOrderTotalCount();
+            //查询待付款订单个数
+            if (orderStatus.getStatus().equals(DmConstant.UN_PAID_CODE)
+                    && orderStatus.getVersion().equals(1)
+                    && orderStatus.getExpire().after(new Date(System.currentTimeMillis()))
+                    && orderStatus.getRefundCode().equals(0)
+
+                    ) {
+                un_pay_order += 1;
+            }
+            //拿到已付款订单
+            if (orderStatus.getStatus().equals(DmConstant.UN_DELIVERY_CODE)
+                    && orderStatus.getVersion().equals(1)
+                    && (orderStatus.getRefundCode().equals(0)
+                    || orderStatus.getRefundCode().equals(4)
+                    || orderStatus.getRefundCode().equals(10))
+                    ) {
+                have_pay_order += 1;
+            }
+
+            //拿到已发货订单
+            if (orderStatus.getStatus().equals(DmConstant.UN_RECEIVE_CODE)
+                    && orderStatus.getVersion().equals(1)
+                    && (orderStatus.getRefundCode().equals(0)
+                    || orderStatus.getRefundCode().equals(4)
+                    || orderStatus.getRefundCode().equals(10))
+                    ) {
+                wait_receive_order += 1;
+            }
+
+            //拿到待晒单订单
+            if (orderStatus.getStatus().equals(DmConstant.UN_SHOW_CODE)
+                    && orderStatus.getVersion().equals(1)
+                    && (orderStatus.getRefundCode().equals(0)
+                    || orderStatus.getRefundCode().equals(4)
+                    || orderStatus.getRefundCode().equals(10))
+                    ) {
+                wait_show_order += 1;
+            }
+
+            //拿到已晒单订单
+            if (orderStatus.getStatus().equals(DmConstant.HAVE_SHOW_CODE)
+                    && orderStatus.getVersion().equals(1)
+                    && (orderStatus.getRefundCode().equals(0)
+                    || orderStatus.getRefundCode().equals(4)
+                    || orderStatus.getRefundCode().equals(10))
+                    ) {
+                have_show_order += 1;
+            }
+
+            //拿到已关闭订单(主动取消或者过期订单)
+            if (orderStatus.getVersion().equals(DmConstant.VERSION_CANCEL_ORDER)
+                    ) {
+                close_order += 1;
+            }
+
+            //拿到退款订单
+            if (orderStatus.getVersion().equals(1)
+                    && (
+                    orderStatus.getRefundCode().equals(1)
+                            || orderStatus.getRefundCode().equals(2)
+                            || orderStatus.getRefundCode().equals(3)
+                            || orderStatus.getRefundCode().equals(5)
+                            || orderStatus.getRefundCode().equals(8)
+                            || orderStatus.getRefundCode().equals(9)
+            )
+                    ) {
+                refund_order += 1;
+            }
+            //拿到退款完成订单
+            if (orderStatus.getVersion().equals(1)
+                    && (orderStatus.getRefundCode().equals(6)
+                    || orderStatus.getRefundCode().equals(7)
+            )
+                    ) {
+                refund_order_over += 1;
+            }
+
+        }
+        map.put("refund_order", refund_order);
+        map.put("refund_order_over", refund_order_over);
+        map.put("close_order", close_order);
+        map.put("have_show_order", have_show_order);
+        map.put("wait_show_order", wait_show_order);
+        map.put("wait_receive_order", wait_receive_order);
+        map.put("have_pay_order", have_pay_order);
+        map.put("un_pay_order", un_pay_order);
+        //总订单数
+        map.put("total_order", total_order);
+        messageModel.setCode(DmConstant.OPS_SUCCESS_CODE);
+        messageModel.setMsg(DmConstant.OPS_SUCCESS_MSG);
+        messageModel.setData(map);
+        return messageModel;
+    }
+
+    /**
+     * @author DY
+     * @create 2018/3/19 14:22
+     * 查看订单
+     */
+    public MessageModel showObligationOrder(OrderDto orderDto, LoginIdentity loginIdentity) {
+        MessageModel messageModel = new MessageModel();
+        orderDto = getOrderDto(orderDto, loginIdentity);
+        Integer status = orderDto.getStatus();
+        //默认refundCode=-1
+        orderDto.setRefundCode(-1);
+        //status 为null 时 查全部
+        if (status == null) {
+
+        } else {
+            //status=0时 查待付款 筛选过期和退款订单
+            if (status == 0) {
+                orderDto.setRefundCode(0);
+                orderDto.setExpire(1);
+                orderDto.setVersion(1);
+
+            }
+            //status=1时 查已付款待发货 筛选过期和退款订单
+            if (status == 1) {
+                orderDto.setRefundCode(0);
+                orderDto.setVersion(1);
+            }
+            //status=2时 查已发货待收货 筛选过期和退款订单
+            if (status == 2) {
+                orderDto.setRefundCode(0);
+                orderDto.setVersion(1);
+            }
+            //status=3时 查已收货待晒单 筛选过期和退款订单
+            if (status == 3) {
+                orderDto.setRefundCode(0);
+                orderDto.setVersion(1);
+            }
+            //status=4时 查晒单 筛选过期和退款订单
+            if (status == 4) {
+                orderDto.setRefundCode(0);
+                orderDto.setVersion(1);
+            }
+            //status=5时 查已关闭订单
+            if (status == 5) {
+                orderDto.setStatus(-1);
+                orderDto.setVersion(-1);
+            }
+
+            //status=6时 查退款订单
+            if (status == 6) {
+                orderDto.setStatus(null);
+                orderDto.setRefundCode(1);
+                orderDto.setVersion(1);
+            }
+
+            //status=7时 查退款完成订单
+            if (status == 7) {
+                orderDto.setStatus(null);
+                orderDto.setRefundCode(2);
+            }
+        }
+
+
+        Map map = new HashMap();
+        // 構建pageBounds
+        PageBounds pageBounds = orderDto.buildPageBounds();
+        //此时拿到所有订单明细然后根据定制明细进行分类
+        List<OrderDetail> order = orderDao.findOrderItemByUserId(orderDto, pageBounds);
+        // 構建返回結果
+        PageList<OrderDetail> orderListStr = (PageList<OrderDetail>) order;
+        List<List<OrderDetail>> newOrderItem = getList(orderListStr);
+        //構建paginator對象返回
+        Paginator paginator = orderListStr.getPaginator();
+        map.put("paginator", paginator);
+
+        //当是未支付订单和全部订单时的时候把使用优惠券的大订单放在一起(暂时先把待支付放在一起)
+        messageModel.setCode(DmConstant.OPS_SUCCESS_CODE);
+        messageModel.setMsg(DmConstant.OPS_SUCCESS_MSG);
+
+        map.put("listOrder", newOrderItem);
+        messageModel.setData(map);
+        return messageModel;
+    }
+
+    private List<List<OrderDetail>> getList(List<OrderDetail> orders) {
+
+        Map<Integer, List> map = new LinkedHashMap();
+
+        for (int i = 0; i < orders.size(); i++) {
+            OrderDetail item = orders.get(i);
+            //构建退款申请最晚同意时间和买家发货之后卖家最晚打款时间
+            Integer refundCode = item.getOrderItemRefundCode();
+            Date refundTime = item.getRefundTime();
+            if (refundCode == DmConstant.REFUND_CODE_APPLY) {
+                Date refundLateTime = new Date(refundTime.getTime() + DmConstant.APPLY_REFUND_IN_REFUND_APPLY);
+                item.setAgreeTimeRefundTime(refundLateTime);
+            }
+            if (refundCode == DmConstant.REFUND_CODE_EXPRESS_NUMBER) {
+                Date refundLateTime = new Date(refundTime.getTime() + DmConstant.APPLY_REFUND_IN_REFUND_HAVE_SEND_REFUND_GOODS);
+                item.setAgreeConfirmTimeRefundTime(refundLateTime);
+            }
+            //构建自动确认收货时间
+            Boolean isExtend = item.getIsExtend();
+            if (item.getDeliveryTime() != null && (refundCode == DmConstant.REFUND_CODE_DEFAULT || refundCode == DmConstant.REFUND_CODE_CANCEL)) {
+                Date time = new Date(item.getDeliveryTime().getTime() + DmConstant.AUTOMATICRECEIVING);
+                if (isExtend) {
+                    time = new Date(time.getTime() + DmConstant.EXTENDTHERECEIVING * 24 * 60 * 60 * 1000);
+                }
+                item.setAutomaticReceivingDate(time);
+            }
+            Integer status = item.getOrderItemStatus();
+            if (refundCode == DmConstant.REFUND_CODE_AGREE && status != 1) {
+                item.setRefundSendDate(new Date(item.getModifyDate().getTime() + DmConstant.APPLY_REFUND_IN_REFUND_AGREE));
+            }
+            Integer key = item.getId();
+            //当且仅当集合里有过 1//1才会进这个集合,第一次也不会进,第二次才会进
+            if (map.containsKey(key)) {
+                map.get(key).add(item);
+            } else {
+                List list = new ArrayList();
+                list.add(item);
+                map.put(key, list);
+            }
+        }
+
+        List<List<OrderDetail>> data = new PageList<>();
+        for (Map.Entry<Integer, List> entry : map.entrySet()) {
+            data.add(entry.getValue());
+        }
+
+        return data;
+
+    }
+
+
+    public void update_receive_address (ReceiveAddress receiveAddress) {
+        AssertUtil.intIsNotEmpty(receiveAddress.getId(), "请选择要修改的订单...");
+        Integer code = orderDao.updateOrderReceiveAddressById(receiveAddress);
+        AssertUtil.intIsNotEmpty(code, "修改失败,请联系客服....");
+    }
+
+   /* *//**
+     * @author DY
+     * @create 2018/3/27 18:31
+     * 修改订单商品信息
+     *//*
+    public MessageModel update_order_property(ProductUpdate productNew) {
+        //参数判断
+        checkParams(productNew);
+        //拿到修改之前订单明细表里的属性
+        ProductUpdate productOld = orderDao.queryProductByOrderItemId(productNew.getOrderItemId());
+        AssertUtil.notNull(productOld, "所查询的商品不存在");
+        Boolean quantity = productNew.getQuantity().equals(productOld.getQuantity());
+        //修改custom属性订单
+        if (StringUtils.isNotBlank(productOld.getCustomNames())) {
+            AssertUtil.isNotEmpty(productNew.getCustomIds(), "请传入定制ids");
+            //默认全部修改--更新订单详情price quantity,custom_names 更改带大订单的价格,数量
+            //拿到新定制的价格
+            List<ProductCustom> productCustoms = orderDao.queryCustomsByCustomId(productNew.getCustomIds());
+            BigDecimal customTotalPrice = BigDecimal.ZERO;
+            StringBuffer sb = new StringBuffer();
+            for (int i = 0; i < productCustoms.size(); i++) {
+                ProductCustom productCustom = productCustoms.get(i);
+                customTotalPrice = customTotalPrice.add(productCustom.getPrice());
+                sb.append(" " + productCustom.getName());
+            }
+            String customNames = sb.toString();
+            //价格=默认价格+新定制价格
+            BigDecimal defaultProductPrice = orderDao.queryDefaultProductPriceByProductId(productOld.getProduct());
+            AssertUtil.notNull(defaultProductPrice, "默认商品不存在,请联系客服...");
+            BigDecimal newPriceOrderItem = defaultProductPrice.add(customTotalPrice);
+            //更新订单详情表
+            Integer code = orderDao.updateOrderItemCustom(newPriceOrderItem, productNew.getQuantity(), customNames, productNew.getOrderItemId());
+            AssertUtil.intIsNotEmpty(code, "更新子订单属性失败,请联系客服....");
+            //更新大订单--差价  差量
+            BigDecimal newPriceTotal = newPriceOrderItem.multiply(new BigDecimal(productNew.getQuantity()));
+            BigDecimal oldPriceTotal = productOld.getPrice().multiply(new BigDecimal(productOld.getQuantity()));
+            BigDecimal differentPrice = newPriceTotal.subtract(oldPriceTotal);
+            Integer differentQuantity = productNew.getQuantity() - productOld.getQuantity();
+            //初始化订单修改对象
+            UpdateOrderParams updateOrderParams = new UpdateOrderParams();
+            updateOrderParams.setOrderId(productOld.getOrders());
+            updateOrderParams.setAmountUpdate(differentPrice);
+            updateOrderParams.setQuantityUpdate(differentQuantity);
+            updateOrderPriceQuantity(updateOrderParams);
+            Map map = new HashMap();
+            map.put("price", newPriceOrderItem);
+            map.put("quantity", productNew.getQuantity());
+            return MessageModelUtil.getSuccessMessageModel(newPriceOrderItem);
+        }
+
+
+
+        //判断修改的是哪一项或者哪几项
+        Boolean scm = productNew.getSize().equals(productOld.getSize()) && productNew.getColor().equals(productOld.getColor())
+                && productNew.getMaterial().equals(productOld.getMaterial());
+        //无任何操作
+        if (scm && quantity) {
+            return MessageModelUtil.getSuccessMessageModel();
+        }
+
+        //初始化订单修改对象
+        UpdateOrderParams updateOrderParams = new UpdateOrderParams();
+        updateOrderParams.setOrderId(productOld.getOrders());
+        //初始化订单明细修改对象
+        ProductUpdate productUpdate = new ProductUpdate();
+        Integer orderItemId = productNew.getOrderItemId();
+        productUpdate.setOrderItemId(orderItemId);
+        //只修改属性
+        if (!scm && quantity) {
+            //拿到修改后的具体商品
+            Product productGetByAttribute = updateProductAttribute(productOld, productNew);
+            //把要修改的属性放进修改对象里
+            productUpdate = updateOrderItemAttribute(productGetByAttribute, orderItemId);
+            updateOrderItem(productUpdate);
+            //单价改变修改大订单价格
+            if (productOld.getPrice().compareTo(productGetByAttribute.getPrice()) != 0) {
+                //拿到差价...
+                BigDecimal differentPriceAmount = productGetByAttribute.getPrice().subtract(productOld.getPrice()).multiply(new BigDecimal(productOld.getQuantity()));
+                //更新大订单的差价
+                updateOrderParams.setAmountUpdate(differentPriceAmount);
+                updateOrderPriceQuantity(updateOrderParams);
+            }
+            Map map = new HashMap();
+            map.put("price", productGetByAttribute.getPrice());
+            map.put("quantity", productNew.getQuantity());
+            return MessageModelUtil.getSuccessMessageModel(map);
+        }
+        //只修改数量--修改子订单数量和大订单数量,金额
+        if (scm && !quantity) {
+            productUpdate.setQuantity(productNew.getQuantity());
+            updateOrderItem(productUpdate);
+            Integer differentQuantity = productNew.getQuantity() - productOld.getQuantity();
+            //修改库存
+            updateQuantityProduct(productOld.getProduct(), differentQuantity);
+            BigDecimal differentPriceAmount = productOld.getPrice().multiply(new BigDecimal(differentQuantity));
+            updateOrderParams.setAmountUpdate(differentPriceAmount);
+            updateOrderParams.setQuantityUpdate(differentQuantity);
+            updateOrderPriceQuantity(updateOrderParams);
+            Map map = new HashMap();
+            map.put("price", productOld.getPrice());
+            map.put("quantity", productNew.getQuantity());
+            return MessageModelUtil.getSuccessMessageModel(map);
+        }
+        //只修改属性和数量
+        if (!scm && !quantity) {
+            //拿到修改后的具体商品
+            Product productGetByAttribute = updateProductAttribute(productOld, productNew);
+            //把要修改的属性放进修改对象里
+            productUpdate = updateOrderItemAttribute(productGetByAttribute, orderItemId);
+            productUpdate.setQuantity(productNew.getQuantity());
+            updateOrderItem(productUpdate);
+            Integer differentQuantity = productNew.getQuantity() - productOld.getQuantity();
+            //拿到修改后的价格
+            BigDecimal priceNew = productGetByAttribute.getPrice().multiply(new BigDecimal(productNew.getQuantity()));
+            //修改前的价格
+            BigDecimal priceOld = productOld.getPrice().multiply(new BigDecimal(productOld.getQuantity()));
+            BigDecimal differentPriceAmount = priceNew.subtract(priceOld);
+            updateOrderParams.setAmountUpdate(differentPriceAmount);
+            updateOrderParams.setQuantityUpdate(differentQuantity);
+            updateOrderPriceQuantity(updateOrderParams);
+            Map map = new HashMap();
+            map.put("price", productGetByAttribute.getPrice());
+            map.put("quantity", productNew.getQuantity());
+            return MessageModelUtil.getSuccessMessageModel(map);
+
+        }
+        return MessageModelUtil.getSuccessMessageModel();
+    }*/
+
+
+    /**
+     * @author DY
+     * @create 2018/3/27 18:31
+     * 修改订单商品信息--更改
+     */
+    public MessageModel update_order_property(ProductUpdate productNew) {
+        //参数判断
+        checkParams(productNew);
+        Map map = new HashMap();
+        //拿到修改之前订单明细表里的属性
+        ProductUpdate productOld = orderDao.queryProductByOrderItemId(productNew.getOrderItemId());
+        AssertUtil.notNull(productOld, "所查询的商品不存在");
+        if (productOld.getIsCustom()) {
+            Integer a = 0;
+            if (null != productNew.getMeasureId()) {
+                a = a + 1;
+            }
+            if (StringUtils.isNotBlank(productNew.getSize())) {
+                a = a + 1;
+            }
+            AssertUtil.isTrue(a == 2, "定制尺码和套码只能而二选一");
+        }
+        Boolean quantity = productNew.getQuantity() == productOld.getQuantity();
+
+        //判断是否修改细节定制
+        Boolean scmDetail = false;
+        if (StringUtils.isNotBlank(productNew.getCustomNamesIds())) {
+            scmDetail = productNew.getCustomNamesIds().equals(productOld.getCustomNamesIds());
+        }
+
+        // 1).定制修改(当且仅当含有细节定制走这一块)
+        if (scmDetail == false) {
+            //默认全部修改--更新订单详情price quantity,custom_names 更改带大订单的价格,数量
+            //拿到细节定制的新价格
+            String customNames = null;
+            BigDecimal customTotalPriceOld = BigDecimal.ZERO;
+            BigDecimal customTotalPriceNew = BigDecimal.ZERO;
+            if (productOld.getCustomNamesIds() != null) {
+                List<ProductCustom> productCustomsOld = orderDao.queryCustomsByCustomId(productOld.getCustomNamesIds());
+                //拿到细节定制的新价格
+                List<ProductCustom> productCustomsNew = orderDao.queryCustomsByCustomId(productNew.getCustomNamesIds());
+                StringBuffer sb = new StringBuffer();
+                for (int i = 0; i < productCustomsOld.size(); i++) {
+                    ProductCustom productCustom = productCustomsOld.get(i);
+                    customTotalPriceOld = customTotalPriceOld.add(productCustom.getPrice());
+                }
+
+                for (int i = 0; i < productCustomsNew.size(); i++) {
+                    ProductCustom productCustom = productCustomsNew.get(i);
+                    customTotalPriceNew = customTotalPriceNew.add(productCustom.getPrice());
+                    sb.append(" " + productCustom.getName());
+                }
+                customNames = sb.toString();
+            }
+            //初始化订单修改对象
+            UpdateOrderParams updateOrderParams = new UpdateOrderParams();
+            updateOrderParams.setOrderId(productOld.getOrders());
+            //初始化订单明细修改对象
+            ProductUpdate productUpdate = new ProductUpdate();
+            Integer orderItemId = productNew.getOrderItemId();
+            productUpdate.setOrderItemId(orderItemId);
+
+            //拿到修改后的具体商品
+            Product newProductUpdate = updateProductAttribute(productOld, productNew);
+            //把要修改的属性放进修改对象里
+            productUpdate = updateOrderItemAttribute(newProductUpdate, orderItemId);
+            productUpdate.setQuantity(productNew.getQuantity());
+            productUpdate.setCustomNames(customNames);
+            productUpdate.setCustomNamesIds(productNew.getCustomNamesIds());
+            productUpdate.setCustomDetailPrice(customTotalPriceNew);
+            //若定制修改量身Id把size置为空,反之亦然
+            if (StringUtils.isNotBlank(productNew.getSize())) {
+                productUpdate.setMeasureId(null);
+            }
+            if (productNew.getMeasureId() != null) {
+                productUpdate.setSize(null);
+            }
+            updateOrderItem(productUpdate);
+
+            Integer differentQuantity = productNew.getQuantity() - productOld.getQuantity();
+            //拿到修改后的价格
+            BigDecimal priceNew = (newProductUpdate.getPrice().add(customTotalPriceNew)).multiply(new BigDecimal(productNew.getQuantity()));
+            //修改前的价格
+            BigDecimal priceOld = (productOld.getPrice().add(customTotalPriceOld)).multiply(new BigDecimal(productOld.getQuantity()));
+            BigDecimal differentPriceAmount = priceNew.subtract(priceOld);
+            updateOrderParams.setAmountUpdate(differentPriceAmount);
+            updateOrderParams.setQuantityUpdate(differentQuantity);
+            updateOrderPriceQuantity(updateOrderParams);
+            map.put("price", newProductUpdate.getPrice().add(customTotalPriceNew));
+            map.put("quantity", productNew.getQuantity());
+            return MessageModelUtil.getSuccessMessageModel(map);
+        }
+
+
+        //判断修改的是哪一项或者哪几项
+        Boolean scm = productNew.getSize().equals(productOld.getSize()) && productNew.getColor().equals(productOld.getColor());
+        //无任何操作
+        if (scm && quantity) {
+            map.put("price", productOld.getPrice());
+            map.put("quantity", productOld.getQuantity());
+            return MessageModelUtil.getSuccessMessageModel(map);
+        }
+
+        //只修改属性
+        if (!scm && quantity) {
+            map = updateAttributeProductOnly(productNew, productOld);
+            return MessageModelUtil.getSuccessMessageModel(map);
+        }
+        //只修改数量--修改子订单数量和大订单数量,金额
+        if (scm && !quantity) {
+            map = updateQuantityProductOnly(productNew, productOld);
+            return MessageModelUtil.getSuccessMessageModel(map);
+        }
+        if (!scm && !quantity) {
+            map = updateAttributeAndQuantityProductOnly(productNew, productOld);
+            return MessageModelUtil.getSuccessMessageModel(map);
+        }
+
+
+        return MessageModelUtil.getSuccessMessageModel();
+    }
+
+    private Map updateAttributeProductOnly(ProductUpdate productNew, ProductUpdate productOld) {
+        //初始化订单修改对象
+        UpdateOrderParams updateOrderParams = new UpdateOrderParams();
+        updateOrderParams.setOrderId(productOld.getOrders());
+        //初始化订单明细修改对象
+        ProductUpdate productUpdate = new ProductUpdate();
+        Integer orderItemId = productNew.getOrderItemId();
+        productUpdate.setOrderItemId(orderItemId);
+        //拿到修改后的具体商品
+        Product newProductUpdate = updateProductAttribute(productOld, productNew);
+        //把要修改的属性放进修改对象里
+        productUpdate = updateOrderItemAttribute(newProductUpdate, orderItemId);
+        productUpdate.setMeasureId(productNew.getMeasureId());
+        //若定制修改量身Id把size置为空,反之亦然
+        if (StringUtils.isNotBlank(productNew.getSize())) {
+            productUpdate.setMeasureId(null);
+        }
+        if (productNew.getMeasureId() != null) {
+            productUpdate.setSize(null);
+        }
+        updateOrderItem(productUpdate);
+        //单价改变修改大订单价格
+        if (productOld.getPrice().compareTo(newProductUpdate.getPrice()) != 0) {
+            //拿到差价...
+            BigDecimal differentPriceAmount = newProductUpdate.getPrice().subtract(productOld.getPrice()).multiply(new BigDecimal(productOld.getQuantity()));
+            //更新大订单的差价
+            updateOrderParams.setAmountUpdate(differentPriceAmount);
+            updateOrderPriceQuantity(updateOrderParams);
+        }
+        Map map = new HashMap();
+        map.put("price", newProductUpdate.getPrice());
+        map.put("quantity", productNew.getQuantity());
+        return map;
+    }
+
+    private Map updateQuantityProductOnly(ProductUpdate productNew, ProductUpdate productOld) {
+        //初始化订单修改对象
+        UpdateOrderParams updateOrderParams = new UpdateOrderParams();
+        updateOrderParams.setOrderId(productOld.getOrders());
+        //初始化订单明细修改对象
+        ProductUpdate productUpdate = new ProductUpdate();
+        Integer orderItemId = productNew.getOrderItemId();
+        productUpdate.setOrderItemId(orderItemId);
+
+        productUpdate.setQuantity(productNew.getQuantity());
+        productUpdate.setMeasureId(productNew.getMeasureId());
+        updateOrderItem(productUpdate);
+        Integer differentQuantity = productNew.getQuantity() - productOld.getQuantity();
+        //套码修改库存
+        if (productOld.getIsCustom() == false) {
+            updateQuantityProduct(productOld.getProduct(), differentQuantity);
+        }
+        BigDecimal differentPriceAmount = productOld.getPrice().multiply(new BigDecimal(differentQuantity));
+        updateOrderParams.setAmountUpdate(differentPriceAmount);
+        updateOrderParams.setQuantityUpdate(differentQuantity);
+        updateOrderPriceQuantity(updateOrderParams);
+        Map map = new HashMap();
+        map.put("price", productOld.getPrice());
+        map.put("quantity", productNew.getQuantity());
+
+        return map;
+    }
+
+
+    private Map updateAttributeAndQuantityProductOnly(ProductUpdate productNew, ProductUpdate productOld) {
+
+        //初始化订单修改对象
+        UpdateOrderParams updateOrderParams = new UpdateOrderParams();
+        updateOrderParams.setOrderId(productOld.getOrders());
+        //初始化订单明细修改对象
+        ProductUpdate productUpdate = new ProductUpdate();
+        Integer orderItemId = productNew.getOrderItemId();
+        productUpdate.setOrderItemId(orderItemId);
+        //拿到修改后的具体商品
+        Product newProductUpdate = updateProductAttribute(productOld, productNew);
+        //把要修改的属性放进修改对象里
+        productUpdate = updateOrderItemAttribute(newProductUpdate, orderItemId);
+        productUpdate.setQuantity(productNew.getQuantity());
+        productUpdate.setMeasureId(productNew.getMeasureId());
+        //若定制修改量身Id把size置为空,反之亦然
+        if (StringUtils.isNotBlank(productNew.getSize())) {
+            productUpdate.setMeasureId(null);
+        }
+        if (productNew.getMeasureId() != null) {
+            productUpdate.setSize(null);
+        }
+        updateOrderItem(productUpdate);
+        Integer differentQuantity = productNew.getQuantity() - productOld.getQuantity();
+        //拿到修改后的价格
+        BigDecimal priceNew = newProductUpdate.getPrice().multiply(new BigDecimal(productNew.getQuantity()));
+        //修改前的价格
+        BigDecimal priceOld = productOld.getPrice().multiply(new BigDecimal(productOld.getQuantity()));
+        BigDecimal differentPriceAmount = priceNew.subtract(priceOld);
+        updateOrderParams.setAmountUpdate(differentPriceAmount);
+        updateOrderParams.setQuantityUpdate(differentQuantity);
+        updateOrderPriceQuantity(updateOrderParams);
+        Map map = new HashMap();
+        map.put("price", newProductUpdate.getPrice());
+        map.put("quantity", productNew.getQuantity());
+        return map;
+    }
+
+
+    private void updateQuantityProduct(Integer productId, Integer quantity) {
+        Integer code = productDao.updateStockOldProduct(productId, quantity);
+        AssertUtil.intIsNotEmpty(code, "修改数量失败....");
+    }
+
+
+    private void updateOrderItem(ProductUpdate productUpdate) {
+        //更改子订单
+        Integer updateOrderItemCode = orderDao.updateOrderItemByProduct(productUpdate);
+        AssertUtil.intIsNotEmpty(updateOrderItemCode, "更改子订单属性smc失败...");
+    }
+
+    private void updateOrderPriceQuantity(UpdateOrderParams updateOrderParams) {
+        Integer updateOrderCode = orderDao.updateOrderByProduct(updateOrderParams);
+        AssertUtil.intIsNotEmpty(updateOrderCode, "修改失败,请联系客服....");
+    }
+
+    private ProductUpdate updateOrderItemAttribute(Product productGetByAttribute, Integer orderItemId) {
+        ProductUpdate productUpdate = new ProductUpdate();
+        productUpdate.setProduct(productGetByAttribute.getId());
+        productUpdate.setOrderItemId(orderItemId);
+        productUpdate.setPrice(productGetByAttribute.getPrice());
+        productUpdate.setColor(productGetByAttribute.getColor());
+        productUpdate.setSize(productGetByAttribute.getSize());
+        return productUpdate;
+    }
+
+    private Product updateProductAttribute(ProductUpdate productOld, ProductUpdate productNew) {
+        Integer quantityOld = productOld.getQuantity();
+        Integer quantityNew = productNew.getQuantity();
+        //拿到商品原信息
+        List<Product> updateProduct = null;
+        Product product = null;
+        //套码
+        Boolean isCustom = productNew.getIsCustom();
+        //定制的话尺寸置为空
+        if (isCustom) {
+            String size = productNew.getSize();
+            productNew.setSize(null);
+            updateProduct = productDao.queryProductBySMC(productNew);
+            AssertUtil.isTrue(updateProduct.isEmpty(), "更改的商品不存在,请稍后重试...");
+            product = updateProduct.get(0);
+            product.setSize(size);
+        } else {
+            updateProduct = productDao.queryProductBySMC(productNew);
+            AssertUtil.isTrue(updateProduct.isEmpty(), "更改的商品不存在,请稍后重试...");
+            product = updateProduct.get(0);
+            //回滚元商品库存,扣去现在商品库存
+            Integer codeOld = productDao.updateStockOldProduct(productOld.getProduct(), -quantityOld);
+            AssertUtil.intIsNotEmpty(codeOld, "回滚库存失败,请联系客服...");
+            Integer codeNew = productDao.updateStockOldProduct(product.getId(), quantityNew);
+            AssertUtil.intIsNotEmpty(codeNew, "扣除库存失败,请联系客服...");
+        }
+        return product;
+
+    }
+
+    private void checkParams(ProductUpdate product) {
+        AssertUtil.intIsNotEmpty(product.getOrderItemId(), "请传入订单明细id...");
+        AssertUtil.intIsNotEmpty(product.getQuantity(), "请传入修改之后的数量...");
+    }
+
+    public void update_order_totalPrice(BigDecimal totalPrice, Integer id) {
+        AssertUtil.intIsNotEmpty(id, "请选择订单...");
+        AssertUtil.notNull(totalPrice, "请传入要修改的价格...");
+        Integer code = orderDao.updateOrderPriceByPrice(totalPrice, id);
+        AssertUtil.intIsNotEmpty(code, "价格修改失败,请联系客服.....");
+    }
+
+    public void updateOrderStatusToSend(String deliverySend) {
+        AssertUtil.isNotEmpty(deliverySend, "请传入发货信息...");
+        //格式化发货大字段
+        List<DeliverySend> deliverySends = null;
+        if (StringUtils.isNotBlank(deliverySend)) {
+            deliverySends = JSON.parseArray(deliverySend, DeliverySend.class);
+        }
+        //更改子订单
+        Integer codeOrderItem = orderDao.updateOrderItemStatusCode(deliverySends);
+        AssertUtil.intIsNotEmpty(codeOrderItem, "更改订单状态失败,请联系客服...");
+        //更改大订单状态,若有多个小订单判断是否全部发货,有一个未发货都不更改大订单
+        for (int i = 0; i < deliverySends.size(); i++) {
+            Integer orderId=deliverySends.get(i).getOrderId();
+            AssertUtil.intIsNotEmpty(orderId, "请传入父订单Id...");
+            Integer isHaveNoSend=orderDao.findOrdersNoSend(orderId,DmConstant.UN_DELIVERY_CODE);
+            if(isHaveNoSend==null||isHaveNoSend<0){
+                Integer code = orderDao.updateOrderStatusAndDelivery(orderId,DmConstant.UN_RECEIVE_CODE);
+                AssertUtil.intIsNotEmpty(code, "更新父订单失败,请稍后重试..."+orderId);
+            }
+        }
+    }
+
+    /*private void updateOrderStatus(Integer orderId, Integer unReceiveCode) {
+        //更改大订单状态
+        Integer codeOrder=orderDao.updateOrderStatus(unReceiveCode,orderId);
+        AssertUtil.intIsNotEmpty(codeOrder,"更改订单状态失败,请联系客服...");
+        //更改子订单
+        Integer codeOrderItem=orderDao.updateOrderItemStatusCode(unReceiveCode,orderId);
+        AssertUtil.intIsNotEmpty(codeOrderItem,"更改订单状态失败,请联系客服...");
+    }*/
+
+    public List<DeliveryCode> query_delivery_code() {
+        List<DeliveryCode> deliveryCodeList = orderDao.queryDeliveryCode();
+        return deliveryCodeList;
+    }
+
+    public void deal_with_return_order(Integer orderItemId, Boolean isAgree,Integer refundCodeF) {
+        AssertUtil.intIsNotEmpty(orderItemId, "请选择带操作的订单");
+        AssertUtil.intIsNotEmpty(refundCodeF, "请传入待退款订单的状态refundCode");
+        AssertUtil.notNull(isAgree, "请选择同意或者拒绝...");
+        Integer refundCode = null;
+        if (isAgree) {
+            refundCode = DmConstant.REFUND_CODE_AGREE;
+            //  3.更新库存
+            //查询待更新订单数量
+            OrderItemDetail orderDetail1 = orderDao.findOrderItemById(orderItemId);
+            //拿到定制类属性,若为空则是套码更新库存,否则不更新
+            Boolean isCustom = orderDetail1.getIsCustom();
+            //套码回滚库存...
+            if (isCustom == false) {
+                Integer quantity = orderDetail1.getQuantity();
+                Integer product = orderDetail1.getProduct();
+                Integer updateProductStock = orderDao.updateProductStock(-quantity, product);
+                AssertUtil.intIsNotEmpty(updateProductStock, "取消订单失败003,请联系客服...");
+            }
+        } else {
+            if(refundCodeF==DmConstant.REFUND_CODE_APPLY||refundCodeF==DmConstant.REFUND_CODE_APPLY_CANCEL_AGAIN){
+                refundCode = DmConstant.REFUND_CODE_REFUSE;
+            }
+            if(refundCodeF==DmConstant.REFUND_CODE_APPLY_REFUSE_AGAIN){
+                refundCode = DmConstant.REFUND_CODE_REFUSE_AGAIN;
+            }
+        }
+        Integer code = orderDao.updateOrderItemRefundStatus(orderItemId, refundCode);
+        AssertUtil.intIsNotEmpty(code, "操作失败,请联系客服...");
+    }
+
+    public void updateOrderStatusToAgree() {
+        //更新到期退款时间订单
+        OrderDto orderDto = new OrderDto();
+        orderDto.setRefundCode(DmConstant.REFUND_CODE_AGREE);
+        orderDto.setRefundTime(DmConstant.REFUND_AGREE_TIME);
+        //更新子订单
+        orderDao.updateOrderItemStatusToAgree(orderDto);
+        //查询待退款订单 refundCode=3子订单
+        orderDto.setRefundCode(DmConstant.REFUND_CODE_AGREE);
+        List<OrderItemQuery> orderDetails = orderDao.findOrderItemByOrderDto(orderDto);
+        //AssertUtil.listIsNotEmpty(orderDetails, "查询失败,请联系客服...");
+        //回滚库存
+      /*  for (int i = 0; i < orderDetails.size(); i++) {
+            OrderItemQuery orderItemQuery = orderDetails.get(i);
+            //拿到定制类属性,若为空则是套码更新库存,否则不更新
+            Boolean isCustom = orderItemQuery.getIsCustom();
+            //套码回滚库存...
+            if (isCustom == false) {
+                Integer quantity = orderItemQuery.getOrderItemQuantity();
+                Integer product = orderItemQuery.getProduct();
+                Integer updateProductStock = orderDao.updateProductStock(-quantity, product);
+                AssertUtil.intIsNotEmpty(updateProductStock, "取消订单失败003,请联系客服...");
+            }
+
+
+        }*/
+        StringBuffer orders = new StringBuffer();
+        if (orderDetails.size() != 0) {
+            for (int i = 0; i < orderDetails.size(); i++) {
+                OrderItemQuery orderItemQuery = orderDetails.get(i);
+                Integer orderId = orderItemQuery.getOrderId();
+                //第一步过滤
+                if (orderItemQuery.getOrderQuantity().equals(orderItemQuery.getOrderItemQuantity())) {
+                    orders.append(orderId + ",");
+                } else {
+                    //查询大订单下子订单是否都是已同意状态,是的话把大订单更改为已同意
+                    String refundCodes = DmConstant.REFUND_CODE_APPLY + "," + DmConstant.REFUND_CODE_REFUSE;
+                    List<Integer> integers = orderDao.findOrderItemByOrderId(orderId, refundCodes);
+                    if (integers.size() == 0) {
+                        orders.append(orderId + ",");
+                    }
+                }
+            }
+        }
+        orders.deleteCharAt(orders.length() - 1);
+        String ordersStr = orders.toString();
+        //批量更新大订单状态
+        orderDao.updateOrderStatusToAgree(ordersStr, DmConstant.REFUND_CODE_AGREE);
+
+    }
+
+    public Integer query_order_refund_status(LoginIdentity loginIdentity) {
+        OrderDto orderDto = getOrderDto(loginIdentity, null);
+        //拿到退款退货订单
+        List<Integer> return_order = orderDao.queryReturnOrder(orderDto);
+        return return_order.size();
+    }
+
+    public void return_order_to_last(Integer orderId,Integer orderItemId,Integer isAgree) {
+        AssertUtil.intIsNotEmpty(orderId, "请确认打款的父订单...");
+        AssertUtil.intIsNotEmpty(orderItemId, "请确认打款的子订单...");
+        AssertUtil.intIsNotEmpty(isAgree, "请确认是否同意...");
+        Integer refundCode=null;
+        if(isAgree==1){
+            refundCode=DmConstant.REFUND_CODE_CONFIRM_RECEIVING;
+        }
+        else if(isAgree==2){
+            refundCode=DmConstant.REFUND_CODE_REFUSE_AGAIN;
+        }
+        else{
+            throw new ParamException("请传入正确的状态值");
+        }
+
+        //更新订单状态
+        Integer code=orderDao.updateOrderItemRefundStatus(orderItemId,refundCode);
+        AssertUtil.intIsNotEmpty(code,"子订单更新失败");
+        if(isAgree==1){
+            //同步大订单状态
+            String refundCodes="1,2,3,5,6,8,9,11";
+            Integer code2=orderDao.findIsHaveRefundOrder(orderId,refundCodes);
+            //没有退款处理中订单更新大订单状态
+            if(code2==null||code2<0){
+                Integer code3=orderDao.updateOrderRefundStatus(orderId,refundCode);
+                AssertUtil.intIsNotEmpty(code3,"父订单更新失败");
+            }
+        }
+
+    }
+}