Преглед на файлове

收益查询修改如参修改

yubin преди 2 седмици
родител
ревизия
56d84d6afe

+ 23 - 9
mall-service/src/main/java/com/txz/mall/business/impl/OrderServiceBusinessImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.txz.cif.dto.EarningsDTO;
+import com.txz.cif.dto.OrderParam;
 import com.txz.mall.business.OrderServiceBusiness;
 import com.txz.mall.core.RedisUtil;
 import com.txz.mall.core.ServiceException;
@@ -85,8 +86,11 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
         UserAddress userAddress = userAddressService.findById(storeOrder.getAddressId());
 
 
-        List<String> orderCodeList = new ArrayList<>();
-        orderCodeList.add(storeOrder.getOrderId());
+        List<OrderParam> orderCodeList = new ArrayList<>();
+        OrderParam orderParam = new OrderParam();
+        orderParam.setOrderNo(storeOrder.getOrderId());
+        orderParam.setUserId(storeOrder.getUid());
+        orderCodeList.add(orderParam);
 
         Map<String, EarningsDTO> collect = new HashMap<>();
         // 查询订单收益
@@ -182,23 +186,33 @@ public class OrderServiceBusinessImpl implements OrderServiceBusiness {
 
 
         if (!CollectionUtils.isEmpty(rank)) {
-            Map<Long, Map<String, Object>> saleMap = rank.stream().collect(Collectors.toMap(a -> Long.valueOf(a.get("combination_id")+"") , a -> a, (b, c) -> c));
-            List<Long> combinationId = rank.stream().map(a -> Long.valueOf(a.get("combination_id")+"")).collect(Collectors.toList());
+            Map<Long, Map<String, Object>> saleMap = rank.stream().collect(Collectors.toMap(a -> Long.valueOf(a.get("pid")+"") , a -> a, (b, c) -> c));
+            List<Long> pidList = rank.stream().map(a -> Long.valueOf(a.get("pid")+"")).collect(Collectors.toList());
+
             Condition storeCombinationCondition = new Condition(StoreCombination.class);
             Example.Criteria storeCombinationCriteria = storeCombinationCondition.createCriteria();
-            storeCombinationCriteria.andIn("id", combinationId);
+            storeCombinationCriteria.andIn("productId", pidList);
             List<StoreCombination> combinationList = storeCombinationService.findByCondition(storeCombinationCondition);
-            for (StoreCombination storeCombination : combinationList) {
-                Map<String, Object> stringObjectMap = saleMap.get(storeCombination.getId());
+            Map<Long, StoreCombination> storeCombinationMap = new HashMap<>();
+            if(!CollectionUtils.isEmpty(combinationList)){
+                 storeCombinationMap = combinationList.stream().collect(Collectors.toMap(StoreCombination::getProductId, a -> a, (b, c) -> c));
+            }
+            for (Map<String, Object> stringObjectMap : rank) {
+
+
+                Object pid = stringObjectMap.get("pid");
+                Object num = stringObjectMap.get("num");
+
+                StoreCombination storeCombination = storeCombinationMap.get(Long.parseLong(pid + ""));
                 StoreCombinationRankVO rankVO = new StoreCombinationRankVO();
                 rankVO.setProductId(storeCombination.getProductId());
                 rankVO.setProductName(storeCombination.getProductName());
-                String num = stringObjectMap.get("num") + "";
-                rankVO.setSales(Integer.valueOf(num));
+                rankVO.setSales(Integer.valueOf(num+""));
                 rankVO.setImage(storeCombination.getImage());
                 rankVO.setPrice(storeCombination.getPrice());
                 list.add(rankVO);
             }
+
             if(!CollectionUtils.isEmpty(list)){
                 list =list.stream().sorted(Comparator.comparing(StoreCombinationRankVO::getSales).reversed()).collect(Collectors.toList());
             }

+ 8 - 2
mall-service/src/main/java/com/txz/mall/business/impl/PinkServiceBusinessImpl.java

@@ -3,6 +3,7 @@ package com.txz.mall.business.impl;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.txz.cif.dto.EarningsDTO;
+import com.txz.cif.dto.OrderParam;
 import com.txz.cif.dto.UserDTO;
 import com.txz.mall.business.PinkServiceBusiness;
 import com.txz.mall.core.ServiceException;
@@ -89,7 +90,12 @@ public class PinkServiceBusinessImpl implements PinkServiceBusiness {
 
 
                 List<String> orderCodeList = pinkList.stream().map(StorePink::getOrderId).collect(Collectors.toList());
-
+                List<OrderParam> orderParamList = pinkList.stream().map(a -> {
+                    OrderParam orderParam = new OrderParam();
+                    orderParam.setUserId(a.getUid());
+                    orderParam.setOrderNo(a.getOrderId());
+                    return orderParam;
+                }).collect(Collectors.toList());
 
                 Condition conditionOrder = new Condition(StoreOrder.class);
                 Example.Criteria criteriaOrder = conditionOrder.createCriteria();
@@ -98,7 +104,7 @@ public class PinkServiceBusinessImpl implements PinkServiceBusiness {
                 List<StoreOrder> storeOrderList = storeOrderService.findByCondition(conditionOrder);
 
                 //查询订单收益
-                List<EarningsDTO> earningsByOrders = cifRedEnvelopeDubboServiceClient.getEarningsByOrders(orderCodeList);
+                List<EarningsDTO> earningsByOrders = cifRedEnvelopeDubboServiceClient.getEarningsByOrders(orderParamList);
                 if(!CollectionUtils.isEmpty(earningsByOrders)){
                     earningsDTOMap = earningsByOrders.stream().filter(a->!ObjectUtils.isEmpty(a)).collect(Collectors.toMap(EarningsDTO::getOrderNo, a -> a, (b, c) -> c));
 

+ 53 - 20
mall-service/src/main/java/com/txz/mall/controller/appcontroller/AppCombinationController.java

@@ -10,16 +10,20 @@ import com.txz.mall.core.Result;
 import com.txz.mall.core.ResultCode;
 import com.txz.mall.core.ServiceException;
 import com.txz.mall.model.StoreCombination;
+import com.txz.mall.model.StoreProduct;
 import com.txz.mall.service.StoreCombinationService;
 import com.txz.mall.service.StoreOrderService;
+import com.txz.mall.service.StoreProductService;
 import com.txz.mall.util.I18nUtil;
 import com.txz.mall.web.param.addparam.StoreCombinationAddParam;
+import com.txz.mall.web.param.result.StoreCombinationVO;
 import com.txz.mall.web.vo.SpuListRO;
 import dto.GoPinkDTO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import tk.mybatis.mapper.entity.Condition;
@@ -27,7 +31,9 @@ import tk.mybatis.mapper.entity.Example;
 import vo.StoreCombinationRankVO;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -185,30 +191,57 @@ public class AppCombinationController {
     //     }
     //     return Result.success(pageInfo);
     // }
-    
+
+    @Resource
+    private StoreProductService storeProductService;
+
     /**
      * 商品列表
      */
-    @GetMapping("app/list")
-    public Result<PageInfo<List<StoreCombination>>> spuList(@Validated SpuListRO ro, Integer page, Integer size) {
+    @GetMapping("/app/list")
+    public Result<PageInfo<List<StoreCombinationVO>>> spuList(@Validated SpuListRO ro, Integer page, Integer size) {
         PageHelper.startPage(page, size);
-        Condition condition = new Condition(StoreCombination.class);
-        Example.Criteria criteria = condition.createCriteria();
-        criteria.andEqualTo("isDelete", 0);
-        criteria.andEqualTo("isShow", 1);
-        
-        if (StrUtil.isNotBlank(ro.getSearchStr())) {
-            criteria.andLike("productName", "%" + ro.getSearchStr() + "%");
-        }
-        if (StrUtil.isNotBlank(ro.getCateId())) {
-            criteria.andEqualTo("cateId", ro.getCateId());
-        }
-        if (ObjectUtil.isNotNull(ro.getPrice())) {
-            criteria.andEqualTo("price", ro.getPrice());
-        }
-        condition.setOrderByClause(ro.getSort().getSort());
-        
-        return Result.success(new PageInfo(storeCombinationService.findByCondition(condition)));
+
+        List<StoreCombinationVO> storeCombinationVOS1 = storeCombinationService.spuList(ro);
+
+//        Condition condition = new Condition(StoreCombination.class);
+//        Example.Criteria criteria = condition.createCriteria();
+//        criteria.andEqualTo("isDelete", 0);
+//        criteria.andEqualTo("isShow", 1);
+//
+//        if (StrUtil.isNotBlank(ro.getStoreName())) {
+//            criteria.andLike("productName", "%" + ro.getStoreName() + "%");
+//        }
+//        if (StrUtil.isNotBlank(ro.getCateId())) {
+//            criteria.andEqualTo("cateId", ro.getCateId());
+//        }
+//        if (ObjectUtil.isNotNull(ro.getPrice())) {
+//            criteria.andEqualTo("price", ro.getPrice());
+//        }
+//        condition.setOrderByClause(ro.getSort().getSort());
+//        List<StoreCombination> byCondition = storeCombinationService.findByCondition(condition);
+//        List<StoreCombinationVO> storeCombinationVOS = new ArrayList<>();
+//
+//        if(!CollectionUtils.isEmpty(byCondition)){
+//            List<Long> productIdList = byCondition.stream().map(StoreCombination::getProductId).collect(Collectors.toList());
+//
+//            Condition conditionStoreProduct = new Condition(StoreProduct.class);
+//            Example.Criteria criteriaStoreProduct = conditionStoreProduct.createCriteria();
+//            criteriaStoreProduct.andEqualTo("isDelete", 0);
+//            criteriaStoreProduct.andIn("id",productIdList);
+//            List<StoreProduct> storeProductList = storeProductService.findByCondition(conditionStoreProduct);
+//            Map<Long, StoreProduct> storeProductMap = storeProductList.stream().collect(Collectors.toMap(StoreProduct::getId, a -> a, (b, c) -> c));
+//            for (StoreCombination storeCombination : byCondition) {
+//                StoreCombinationVO storeCombinationVO = new StoreCombinationVO();
+//                BeanUtils.copyProperties(storeCombination,storeCombinationVO);
+//                StoreProduct storeProduct = storeProductMap.get(storeCombination.getProductId());
+//                storeCombinationVO.setFicti(storeProduct.getFicti());
+//                storeCombinationVOS.add(storeCombinationVO);
+//            }
+//        }
+
+
+        return Result.success(new PageInfo(storeCombinationVOS1));
     }
     
     

+ 9 - 0
mall-service/src/main/java/com/txz/mall/dao/StoreCombinationMapper.java

@@ -3,6 +3,8 @@ package com.txz.mall.dao;
 import com.txz.mall.core.Mapper;
 import com.txz.mall.dao.impl.StoreCombinationMapperImpl;
 import com.txz.mall.model.StoreCombination;
+import com.txz.mall.web.param.result.StoreCombinationVO;
+import com.txz.mall.web.vo.SpuListRO;
 import dto.StoreProductAddRequest;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.SelectProvider;
@@ -17,4 +19,11 @@ public interface StoreCombinationMapper extends Mapper<StoreCombination> {
     
     @SelectProvider(type = StoreCombinationMapperImpl.class, method = "getIdByProductId")
     Long getIdByProductId(Long productId);
+
+
+//    @Select("SELECT id,product_id,activity_id,product_name,cate_id,image,images,title,attr,people,info,price,sort,sales,stock,is_new,is_hot,is_show,combination,is_postage,postage,start_time,stop_time,effective_time,cost,browse,unit_name,temp_id,weight,volume,num,quota,quota_show,ot_price,once_num,virtual_ration,create_time,update_time,create_user_id,update_user_id,is_delete,version FROM m_store_combination left join m_store_product on m_store_combination.product_id = m_store_product.id  WHERE  is_delete = 0 and is_show = 1 and price = ? and cate_id =? and product_name = ? \n" +
+//            "\n" +
+//            " order by sales desc LIMIT ?")
+    List<StoreCombinationVO> spuList(SpuListRO ro);
+
 }

+ 1 - 1
mall-service/src/main/java/com/txz/mall/dao/StorePinkMapper.java

@@ -18,7 +18,7 @@ public interface StorePinkMapper extends Mapper<StorePink> {
     List<ProductCarouselDTO> pinkByProductId(Long productId);
 
 
-    @Select("select cid as combination_id ,count(*) as num from m_store_pink where (order_status in (7,5,8,6) or l_id in(1) )and create_time > #{date} group by cid ORDER BY num desc limit 20")
+    @Select("select pid as pid ,count(*) as num from m_store_pink where (order_status in (3,4,5,6,7,8) or l_id in(1) )and create_time > #{date} group by pid ORDER BY num desc limit 20")
     List<Map<String,Object>> getRank(@Param("date") Date date);
     
 }

+ 3 - 2
mall-service/src/main/java/com/txz/mall/dubbo/client/CifRedEnvelopeDubboServiceClient.java

@@ -1,6 +1,7 @@
 package com.txz.mall.dubbo.client;
 
 import com.txz.cif.dto.EarningsDTO;
+import com.txz.cif.dto.OrderParam;
 import com.txz.cif.service.AccountDubboService;
 import com.txz.cif.service.RedEnvelopeDubboService;
 import lombok.extern.slf4j.Slf4j;
@@ -17,8 +18,8 @@ public class CifRedEnvelopeDubboServiceClient {
     private RedEnvelopeDubboService redEnvelopeDubboService;
 
 
-   public List<EarningsDTO> getEarningsByOrders(List<String> var1){
-       return redEnvelopeDubboService.getEarningsByOrders(var1);
+   public List<EarningsDTO> getEarningsByOrders(List<OrderParam> params){
+       return redEnvelopeDubboService.getEarningsByOrders(params);
    }
 
 

+ 10 - 0
mall-service/src/main/java/com/txz/mall/service/StoreCombinationService.java

@@ -1,7 +1,12 @@
 package com.txz.mall.service;
 
+import com.github.pagehelper.PageInfo;
+import com.txz.mall.core.Result;
 import com.txz.mall.core.Service;
 import com.txz.mall.model.StoreCombination;
+import com.txz.mall.web.param.result.StoreCombinationVO;
+import com.txz.mall.web.vo.SpuListRO;
+import org.springframework.validation.annotation.Validated;
 
 import java.util.List;
 
@@ -40,4 +45,9 @@ public interface StoreCombinationService extends Service<StoreCombination> {
      * @param type 类型:add—添加,sub—扣减
      */
     void operationStock(Long id, Integer num, String type);
+
+
+    List<StoreCombinationVO> spuList(SpuListRO ro);
+
+
 }

+ 9 - 0
mall-service/src/main/java/com/txz/mall/service/impl/StoreCombinationServiceImpl.java

@@ -14,6 +14,8 @@ import com.txz.mall.service.StoreFlashActivityService;
 import com.txz.mall.service.StorePinkService;
 import com.txz.mall.service.StoreProductService;
 import com.txz.mall.util.I18nUtil;
+import com.txz.mall.web.param.result.StoreCombinationVO;
+import com.txz.mall.web.vo.SpuListRO;
 import lombok.AllArgsConstructor;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
@@ -206,4 +208,11 @@ public class StoreCombinationServiceImpl extends AbstractService<StoreCombinatio
 //        }
 //        update(combination);
 //    }
+
+
+    @Override
+    public List<StoreCombinationVO> spuList(SpuListRO ro) {
+        List<StoreCombinationVO> storeCombinationVOS = storeCombinationMapper.spuList(ro);
+        return storeCombinationVOS;
+    }
 }

+ 3 - 0
mall-service/src/main/java/com/txz/mall/service/impl/StoreProductServiceImpl.java

@@ -388,6 +388,9 @@ public class StoreProductServiceImpl extends AbstractService<StoreProduct> imple
 
             forUpdatestoreProduct.setStock(stock);
             forUpdatestoreProduct.setSales(sales);
+            //累计虚拟销量,虚拟销量和下单数挂钩,和是否退款或者成团或者是否中奖都无关  只累加不扣减
+            int ficti = storeProduct.getFicti()+num;
+            forUpdatestoreProduct.setFicti(ficti);
 
         }
         if ("sub".equals(type)) {

+ 18 - 0
mall-service/src/main/java/com/txz/mall/web/param/result/StoreCombinationVO.java

@@ -0,0 +1,18 @@
+package com.txz.mall.web.param.result;
+
+import com.txz.mall.model.StoreCombination;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class StoreCombinationVO extends StoreCombination implements Serializable {
+
+    /**
+     * 虚拟销量
+     */
+    @ApiModelProperty(value = "虚拟销量")
+    private Integer ficti;
+
+}

+ 1 - 1
mall-service/src/main/java/com/txz/mall/web/vo/SpuListRO.java

@@ -16,7 +16,7 @@ public class SpuListRO {
     /**
      * 搜索关键字
      */
-    private String searchStr;
+    private String storeName;
     
     /**
      * 分类id

+ 125 - 0
mall-service/src/main/resources/mapper/StoreCombinationMapper.xml

@@ -48,4 +48,129 @@
         <result column="activity_id" jdbcType="BIGINT" property="activityId"/>
         <result column="is_new" jdbcType="INTEGER" property="isNew"/>
     </resultMap>
+
+
+    <resultMap id="storeCombinationVOMap" type="com.txz.mall.web.param.result.StoreCombinationVO">
+        <!--
+          WARNING - @mbg.generated
+        -->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="product_id" jdbcType="BIGINT" property="productId"/>
+        <result column="product_name" jdbcType="VARCHAR" property="productName"/>
+        <result column="mer_id" jdbcType="BIGINT" property="merId"/>
+        <result column="image" jdbcType="VARCHAR" property="image"/>
+        <result column="images" jdbcType="VARCHAR" property="images"/>
+        <result column="title" jdbcType="VARCHAR" property="title"/>
+        <result column="attr" jdbcType="VARCHAR" property="attr"/>
+        <result column="people" jdbcType="INTEGER" property="people"/>
+        <result column="info" jdbcType="VARCHAR" property="info"/>
+        <result column="price" jdbcType="DECIMAL" property="price"/>
+        <result column="sort" jdbcType="INTEGER" property="sort"/>
+        <result column="sales" jdbcType="INTEGER" property="sales"/>
+        <result column="stock" jdbcType="INTEGER" property="stock"/>
+        <result column="is_hot" jdbcType="INTEGER" property="isHot"/>
+        <result column="is_show" jdbcType="INTEGER" property="isShow"/>
+        <result column="combination" jdbcType="INTEGER" property="combination"/>
+        <result column="mer_use" jdbcType="INTEGER" property="merUse"/>
+        <result column="is_postage" jdbcType="INTEGER" property="isPostage"/>
+        <result column="postage" jdbcType="DECIMAL" property="postage"/>
+        <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
+        <result column="stop_time" jdbcType="TIMESTAMP" property="stopTime"/>
+        <result column="effective_time" jdbcType="INTEGER" property="effectiveTime"/>
+        <result column="cost" jdbcType="DECIMAL" property="cost"/>
+        <result column="browse" jdbcType="INTEGER" property="browse"/>
+        <result column="unit_name" jdbcType="VARCHAR" property="unitName"/>
+        <result column="temp_id" jdbcType="BIGINT" property="tempId"/>
+        <result column="weight" jdbcType="DECIMAL" property="weight"/>
+        <result column="volume" jdbcType="DECIMAL" property="volume"/>
+        <result column="num" jdbcType="INTEGER" property="num"/>
+        <result column="quota" jdbcType="INTEGER" property="quota"/>
+        <result column="quota_show" jdbcType="INTEGER" property="quotaShow"/>
+        <result column="ot_price" jdbcType="DECIMAL" property="otPrice"/>
+        <result column="once_num" jdbcType="INTEGER" property="onceNum"/>
+        <result column="virtual_ration" jdbcType="INTEGER" property="virtualRation"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+        <result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
+        <result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
+        <result column="is_delete" jdbcType="INTEGER" property="isDelete"/>
+        <result column="activity_id" jdbcType="BIGINT" property="activityId"/>
+        <result column="is_new" jdbcType="INTEGER" property="isNew"/>
+        <result column="ficti" jdbcType="INTEGER" property="ficti"/>
+
+    </resultMap>
+
+
+    <select id="spuList" resultMap="storeCombinationVOMap" parameterType="com.txz.mall.web.vo.SpuListRO">
+
+        SELECT
+        m_store_combination.id,
+        m_store_combination.product_id,
+        m_store_combination.activity_id,
+        m_store_combination.product_name,
+        m_store_combination.cate_id,
+        m_store_combination.image,
+        m_store_combination.images,
+        m_store_combination.title,
+        m_store_combination.attr,
+        m_store_combination.people,
+        m_store_combination.info,
+        m_store_combination.price,
+        m_store_combination.sort,
+        m_store_combination.sales,
+        m_store_combination.stock,
+        m_store_combination.is_new,
+        m_store_combination.is_hot,
+        m_store_combination.is_show,
+        m_store_combination.combination,
+        m_store_combination.is_postage,
+        m_store_combination.postage,
+        m_store_combination.start_time,
+        m_store_combination.stop_time,
+        m_store_combination.effective_time,
+        m_store_combination.cost,
+        m_store_combination.browse,
+        m_store_combination.unit_name,
+        m_store_combination.temp_id,
+        m_store_combination.weight,
+        m_store_combination.volume,
+        m_store_combination.num,
+        m_store_combination.quota,
+        m_store_combination.quota_show,
+        m_store_combination.ot_price,
+        m_store_combination.once_num,
+        m_store_combination.virtual_ration,
+        m_store_combination.create_time,
+        m_store_combination.update_time,
+        m_store_combination.create_user_id,
+        m_store_combination.update_user_id,
+        m_store_combination.is_delete,
+        m_store_combination.version,
+        m_store_product.ficti
+        FROM m_store_combination left join m_store_product on m_store_combination.product_id = m_store_product.id
+        WHERE m_store_combination.is_delete = 0 and m_store_combination.is_show = 1
+        <if test="price != null">
+          AND m_store_combination.price = #{price}
+        </if>
+        <if test="cateId != null">
+          AND m_store_combination.cate_id = #{cateId}
+        </if>
+        <if test="storeName != null and storeName != ''">
+          AND m_store_combination.product_name = #{storeName}
+        </if>
+
+        <choose>
+            <when test="sort == @com.txz.mall.enums.SpuSortEnum@SALES_DESC">
+                ORDER BY m_store_product.ficti desc
+            </when>
+            <when test="sort == @com.txz.mall.enums.SpuSortEnum@CREATE_DESC">
+                ORDER BY m_store_combination.create_time desc
+            </when>
+            <otherwise>
+                order by m_store_product.ficti desc
+            </otherwise>
+        </choose>
+
+     </select>
+
 </mapper>