Bläddra i källkod

直播导出调整

lmx 5 dagar sedan
förälder
incheckning
5cb01c914a

+ 5 - 3
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreAfterSalesScrmController.java

@@ -33,6 +33,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.text.ParseException;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * 售后记录Controller
@@ -84,16 +85,17 @@ public class FsStoreAfterSalesScrmController extends BaseController
             fsStoreAfterSales.setBeginTime(null);
             fsStoreAfterSales.setEndTime(null);
         }
-        Boolean a = fsStoreAfterSalesService.isEntityNull(fsStoreAfterSales);
-        if (fsStoreAfterSalesService.isEntityNull(fsStoreAfterSales)){
+//        Boolean a = fsStoreAfterSalesService.isEntityNull(fsStoreAfterSales);
+        if (fsStoreAfterSalesService.isEntityNull(fsStoreAfterSales) && Objects.isNull(fsStoreAfterSales.getParams())){
             return AjaxResult.error("请筛选数据导出");
         }
+
         List<FsStoreAfterSalesVO> list = fsStoreAfterSalesService.selectFsStoreAfterSalesListVO(fsStoreAfterSales);
         for (FsStoreAfterSalesVO vo : list){
             vo.setUserPhone(ParseUtils.parsePhone(vo.getUserPhone()));
         }
         ExcelUtil<FsStoreAfterSalesVO> util = new ExcelUtil<FsStoreAfterSalesVO>(FsStoreAfterSalesVO.class);
-        return util.exportExcel(list, "storeAfterSales");
+        return util.exportExcel(list, "退款订单导出");
     }
     /**
      * 获取售后记录详细信息

+ 9 - 2
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreAfterSalesScrmMapper.java

@@ -87,8 +87,15 @@ public interface FsStoreAfterSalesScrmMapper
     List<FsStoreAfterSalesQueryVO>  selectFsStoreAfterSalesListQuery(@Param("maps") FsStoreAfterSalesQueryParam storeAfterSalesParam);
 
     @Select({"<script> " +
-            "select s.*,o.delivery_status,o.delivery_id,u.phone as user_phone,c.company_name ,cu.nick_name as company_user_nick_name ,cu.phonenumber as company_usere_phonenumber  from fs_store_after_sales_scrm s INNER join fs_store_order_scrm o on o.order_code=s.order_code left join fs_user u on s.user_id=u.user_id left join company c on c.company_id=s.company_id left join company_user cu on cu.user_id=s.company_user_id " +
-            "where 1=1 " +
+            "select s.*,o.delivery_status,o.delivery_id,u.phone as user_phone,c.company_name ,cu.nick_name as company_user_nick_name ," +
+            "cu.phonenumber as company_usere_phonenumber,o.id as orderId,o.real_name as userName,o.item_json,o.user_address,o.pay_time as orderPayTime,o.pay_price,o.total_postage,fsps.bank_serial_no  " +
+            " from fs_store_after_sales_scrm s " +
+            " INNER join fs_store_order_scrm o on o.order_code=s.order_code " +
+            " left join fs_user u on s.user_id=u.user_id " +
+            " left join company c on c.company_id=s.company_id " +
+            " left join company_user cu on cu.user_id=s.company_user_id " +
+            " left join fs_store_payment_scrm fsps on fsps.business_order_id = s.id and fsps.status in (-1,1) " +
+            " where 1=1 " +
             "<if test = 'maps.status != null    '> " +
             "and s.status = #{maps.status} " +
             "</if>" +

+ 4 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreOrderItemScrmMapper.java

@@ -274,4 +274,8 @@ public interface FsStoreOrderItemScrmMapper
 
     @Select("select product_id,json_info,num from fs_store_order_item_scrm where order_id=#{orderId}")
     List<FsStoreOrderItemListDVO> selectFsStoreOrderItemListDVOByOrderId(Long orderId);
+
+
+
+    List<FsStoreOrderItemVO> selectFsStoreOrderItemListByOrderIds(@Param("orderIds")List<Long> orderIds);
 }

+ 36 - 2
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreAfterSalesScrmServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.annotation.DataScope;
 import com.fs.common.annotation.RepeatSubmit;
@@ -42,6 +43,7 @@ import com.fs.hisStore.param.*;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
 import com.fs.huifuPay.service.HuiFuService;
+import com.fs.live.vo.LiveOrderItemListUVO;
 import com.fs.pay.service.IPayService;
 import com.fs.hisStore.config.StoreConfig;
 import com.fs.hisStore.domain.*;
@@ -84,6 +86,7 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 售后记录Service业务层处理
@@ -551,9 +554,40 @@ public class FsStoreAfterSalesScrmServiceImpl implements IFsStoreAfterSalesScrmS
     }
 
     @Override
-    @DataScope(deptAlias = "cu",userAlias = "cu")
+    @DataScope(deptAlias = "cu", userAlias = "cu")
     public List<FsStoreAfterSalesVO> selectFsStoreAfterSalesListVO(FsStoreAfterSalesScrm fsStoreAfterSales) {
-        return fsStoreAfterSalesMapper.selectFsStoreAfterSalesListVO(fsStoreAfterSales);
+        List<FsStoreAfterSalesVO> fsStoreAfterSalesVOS = fsStoreAfterSalesMapper.selectFsStoreAfterSalesListVO(fsStoreAfterSales);
+        List<Long> orderIds = new ArrayList<>();
+        Map<Long, List<FsStoreOrderItemVO>> orderItemMap = new HashMap<>();
+        if(null != fsStoreAfterSalesVOS && !fsStoreAfterSalesVOS.isEmpty()){
+            orderIds = fsStoreAfterSalesVOS.stream().map(e -> e.getOrderId()).collect(Collectors.toList());
+            if(null != orderIds && !orderIds.isEmpty()){
+                List<FsStoreOrderItemVO> fsStoreOrderItemVOS = fsStoreOrderItemMapper.selectFsStoreOrderItemListByOrderIds(orderIds);
+                orderItemMap = fsStoreOrderItemVOS.stream()
+                        .collect(Collectors.groupingBy(FsStoreOrderItemVO::getOrderId));
+            }
+        }
+        boolean mapEmpty = orderItemMap.isEmpty();
+        if (null != fsStoreAfterSalesVOS && !fsStoreAfterSalesVOS.isEmpty()) {
+            for (FsStoreAfterSalesVO item : fsStoreAfterSalesVOS) {
+                if(!mapEmpty && orderItemMap.containsKey(item.getOrderId())){
+                    List<FsStoreOrderItemVO> orderItems = orderItemMap.get(item.getOrderId());
+                    for (FsStoreOrderItemVO orderItem : orderItems) {
+                        try {
+                            JSONObject jsO = JSONObject.parseObject(orderItem.getJsonInfo());
+                            item.setProductName(StringUtils.isNotBlank(item.getProductName()) ? item.getProductName() + "," + jsO.getString("productName") : jsO.getString("productName"));
+                            item.setProductBarCode(StringUtils.isNotBlank(item.getProductBarCode()) ? item.getProductBarCode() + "," + jsO.getString("barCode") : jsO.getString("barCode"));
+                            item.setSku(StringUtils.isNotBlank(item.getSku()) ? item.getSku() + "," + jsO.getString("sku") : jsO.getString("sku"));
+                            item.setNum(StringUtils.isNotBlank(item.getNum()) ? item.getNum() + "," + jsO.getString("num") : jsO.getString("num"));
+                            item.setPrice(StringUtils.isNotBlank(item.getPrice()) ? item.getPrice() + "," + jsO.getString("price") : jsO.getString("price"));
+                        } catch (Exception ex) {
+                            logger.error("售后订单商品信息转换异常",ex);
+                        }
+                    }
+                }
+            }
+        }
+        return fsStoreAfterSalesVOS;
     }
 
 //    @Override

+ 28 - 1
fs-service/src/main/java/com/fs/hisStore/vo/FsStoreAfterSalesVO.java

@@ -100,7 +100,34 @@ public class FsStoreAfterSalesVO implements Serializable
     @Excel(name = "提交时间",width =30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
 
-
+    private String itemJson;
+
+    @Excel(name = "用户名称")
+    private String userName;
+    @Excel(name ="产品名称")
+    private String productName;
+    @Excel(name ="产品编码")
+    private String productBarCode;
+    @Excel(name ="规格")
+    private String sku;
+    @Excel(name ="产品数量")
+    private String num;
+    @Excel(name ="产品价格")
+    private String price;
+    @Excel(name="额外运费")
+    private BigDecimal totalPostage;
+    @Excel(name="实付金额")
+    private BigDecimal payPrice;
+    //    @Excel(name="收货人姓名")
+//    private String realName;
+    @Excel(name ="详细地址")
+    private  String userAddress;
+    @Excel(name ="支付时间" ,dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date orderPayTime;
+    @Excel(name ="银行交易流水号")
+    private String bankSerialNo;
+
+    private Long orderId;
 
 
 }

+ 3 - 0
fs-service/src/main/java/com/fs/live/mapper/LiveOrderItemMapper.java

@@ -166,4 +166,7 @@ public interface LiveOrderItemMapper {
             " order by o.id desc limit 50000"+
             "</script>"})
     List<LiveOrderItemExportVO> selectFsStoreOrderItemListExportVO(@Param("maps") LiveOrderParam fsStoreOrder);
+
+
+    List<LiveOrderItemListUVO> selectLiveOrderItemListUVOByOrderIds(@Param("orderIds")List<Long> orderIds);
 }

+ 49 - 4
fs-service/src/main/java/com/fs/live/service/impl/LiveAfterSalesServiceImpl.java

@@ -5,6 +5,7 @@ import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateTime;
@@ -12,6 +13,7 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
@@ -56,10 +58,7 @@ import com.fs.live.param.*;
 import com.fs.live.service.ILiveOrderItemService;
 import com.fs.live.service.ILiveOrderLogsService;
 import com.fs.live.service.ILiveOrderService;
-import com.fs.live.vo.LiveAfterSalesListUVO;
-import com.fs.live.vo.LiveAfterSalesQueryVO;
-import com.fs.live.vo.LiveAfterSalesVo;
-import com.fs.live.vo.LiveOrderItemVO1;
+import com.fs.live.vo.*;
 import com.fs.store.config.StoreConfig;
 import com.fs.store.domain.*;
 import com.fs.store.service.cache.IFsUserCacheService;
@@ -201,6 +200,17 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
     public List<LiveAfterSalesVo> selectLiveAfterSalesVoList(LiveAfterSalesVo liveAfterSales)
     {
         List<LiveAfterSalesVo> liveAfterSalesVos = baseMapper.selectLiveAfterSalesVoList(liveAfterSales);
+        List<Long> orderIds = new ArrayList<>();
+        Map<Long, List<LiveOrderItemListUVO>> orderItemMap = new HashMap<>();
+        if(null != liveAfterSalesVos && !liveAfterSalesVos.isEmpty()){
+            orderIds = liveAfterSalesVos.stream().map(e -> e.getOrderId()).collect(Collectors.toList());
+            if(null != orderIds && !orderIds.isEmpty()){
+                List<LiveOrderItemListUVO> liveOrderItemListUVOS = liveOrderItemMapper.selectLiveOrderItemListUVOByOrderIds(orderIds);
+                orderItemMap = liveOrderItemListUVOS.stream()
+                        .collect(Collectors.groupingBy(LiveOrderItemListUVO::getOrderId));
+            }
+        }
+        boolean mapEmpty = orderItemMap.isEmpty();
         for (LiveAfterSalesVo item : liveAfterSalesVos) {
             if(ObjectUtil.isNotNull(item.getUserId())) {
                 FsUser fsUser = fsUserCacheService.selectFsUserById(item.getUserId());
@@ -217,6 +227,41 @@ public class LiveAfterSalesServiceImpl implements ILiveAfterSalesService {
                 item.setCompanyName("-");
             }
 
+            if(!mapEmpty && orderItemMap.containsKey(item.getOrderId())){
+                List<LiveOrderItemListUVO> liveOrderItemListUVOS = orderItemMap.get(item.getOrderId());
+                for (LiveOrderItemListUVO liveOrderItemListUVO : liveOrderItemListUVOS) {
+                    try {
+                        JSONObject jsO = JSONObject.parseObject(liveOrderItemListUVO.getJsonInfo());
+                        item.setProductName(StringUtils.isNotBlank(item.getProductName()) ? item.getProductName() + "," + jsO.getString("productName") : jsO.getString("productName"));
+                        item.setProductBarCode(StringUtils.isNotBlank(item.getProductBarCode()) ? item.getProductBarCode() + "," + jsO.getString("barCode") : jsO.getString("barCode"));
+                        item.setSku(StringUtils.isNotBlank(item.getSku()) ? item.getSku() + "," + jsO.getString("sku") : jsO.getString("sku"));
+                        item.setNum(StringUtils.isNotBlank(item.getNum()) ? item.getNum() + "," + jsO.getString("num") : jsO.getString("num"));
+                        item.setPrice(StringUtils.isNotBlank(item.getPrice()) ? item.getPrice() + "," + jsO.getString("price") : jsO.getString("price"));
+                    } catch (Exception ex) {
+                        log.error("售后订单商品信息转换异常",ex);
+                    }
+                }
+            }
+//            if (StringUtils.isNotBlank(item.getItemJson())) {
+//                try {
+//                    JSONArray array = JSONObject.parseArray(item.getItemJson());
+//                    if(null != array && !array.isEmpty()){
+//                        for (Object o : array) {
+//                            JSONObject jsO = (JSONObject) o;
+//                            item.setProductName(StringUtils.isNotBlank(item.getProductName())?item.getProductName()+","+jsO.getString("productName"):jsO.getString("productName"));
+//                            item.setProductBarCode(StringUtils.isNotBlank(item.getProductBarCode())?item.getProductBarCode()+","+jsO.getString("barCode"):jsO.getString("barCode"));
+//                            item.setSku(StringUtils.isNotBlank(item.getSku())?item.getSku()+","+jsO.getString("sku"):jsO.getString("sku"));
+//                            item.setNum(null != item.getNum()?item.getNum() +jsO.getInteger("num"):jsO.getInteger("num"));
+//                            item.setPrice(null != item.getPrice()?item.getPrice().add(jsO.getBigDecimal("price")):jsO.getBigDecimal("price"));
+//                        }
+//                    }
+//                } catch (Exception ex) {
+//                    log.error("售后订单商品信息转换异常",ex);
+//                }
+//
+//            }
+
+
 //            if(ObjectUtil.isNotNull(item.getOrderId())){
 //                List<FsStoreDelivers> byOrderIdWithType = fsStoreDeliversService.findByOrderIdWithType(item.getOrderId(), 1);
 //                if(CollectionUtils.isNotEmpty(byOrderIdWithType)) {

+ 29 - 1
fs-service/src/main/java/com/fs/live/vo/LiveAfterSalesVo.java

@@ -108,7 +108,7 @@ public class LiveAfterSalesVo {
     /** 用户id */
     @Excel(name = "用户id")
     private Long userId;
-    //    @Excel(name = "用户名称")
+    @Excel(name = "用户名称")
     private String userName;
 
     /** 商家收货人 */
@@ -147,4 +147,32 @@ public class LiveAfterSalesVo {
      */
     private String deliveryId;
 
+    private String itemJson;
+
+    @Excel(name ="产品名称")
+    private String productName;
+    @Excel(name ="产品编码")
+    private String productBarCode;
+    @Excel(name ="规格")
+    private String sku;
+    @Excel(name ="产品数量")
+    private String num;
+    @Excel(name ="产品价格")
+    private String price;
+    @Excel(name="额外运费")
+    private BigDecimal totalPostage;
+    @Excel(name="实付金额")
+    private BigDecimal payPrice;
+//    @Excel(name="收货人姓名")
+//    private String realName;
+    @Excel(name ="详细地址")
+    private  String userAddress;
+    @Excel(name ="支付时间" ,dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date orderPayTime;
+    @Excel(name ="银行交易流水号")
+    private String bankSerialNo;
+
+
+
+
 }

+ 1 - 0
fs-service/src/main/java/com/fs/live/vo/LiveOrderItemListUVO.java

@@ -7,6 +7,7 @@ import java.io.Serializable;
 @Data
 public class LiveOrderItemListUVO implements Serializable {
 
+    private Long orderId;
     /** 商品ID */
     private Long productId;
     private Long itemId;

+ 7 - 0
fs-service/src/main/resources/mapper/hisStore/FsStoreOrderItemScrmMapper.xml

@@ -95,4 +95,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </delete>
 
+    <select id="selectFsStoreOrderItemListByOrderIds" resultType="com.fs.hisStore.vo.FsStoreOrderItemVO" parameterType="java.util.List" >
+        select * from fs_store_order_item_scrm where order_id in
+        <foreach item="itemId" collection="orderIds" open="(" separator="," close=")">
+            #{itemId}
+        </foreach>
+    </select>
+
 </mapper>

+ 2 - 1
fs-service/src/main/resources/mapper/live/LiveAfterSalesMapper.xml

@@ -66,11 +66,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select las.id, las.live_id, las.store_id, las.order_id, las.refund_amount,
         las.refund_type, las.reasons, las.explains, las.explain_img, las.delivery_code, las.delivery_sn, las.delivery_name, las.status, las.sales_status,
         las.order_status, las.create_time, las.is_del, las.user_id, las.consignee, las.phone_number, las.address, las.company_id, las.company_user_id, las.dept_id,
-        cu.nick_name as company_user_nick_name, c.company_name,lo.order_code,lo.user_phone,las.user_id
+        cu.nick_name as company_user_nick_name, c.company_name,lo.order_id,lo.order_code,lo.user_phone,las.user_id,lo.item_json,lo.pay_time as orderPayTime,lo.user_address,lo.user_name,lo.pay_price,lo.total_postage,lop.bank_serial_no
         from live_after_sales las
         left join live_order lo on lo.order_id = las.order_id
         left join company_user cu on cu.user_id = las.company_user_id
         left join company c on c.company_id = cu.company_id
+        left join live_order_payment lop on lop.business_id = lo.order_id and lop.status in (1,-1)
 
         <where>
             <if test="liveId != null and liveId != ''"> and las.live_id = #{liveId}</if>

+ 9 - 0
fs-service/src/main/resources/mapper/live/LiveOrderItemMapper.xml

@@ -148,4 +148,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{itemId}
         </foreach>
     </delete>
+
+    <select id="selectLiveOrderItemListUVOByOrderIds" resultType="com.fs.live.vo.LiveOrderItemListUVO"  parameterType="java.util.List">
+        select product_id,json_info,order_code,item_id,num,order_id from live_order_item
+        where order_id in
+        <foreach item="itemId" collection="orderIds" open="(" separator="," close=")">
+            #{itemId}
+        </foreach>
+
+    </select>
 </mapper>