From 437d7c45481176d4766152cae26cf841a8bd458f Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期三, 21 一月 2026 14:57:56 +0800
Subject: [PATCH] 经销商管理

---
 server/dmmall_service/src/main/java/com/doumee/service/business/impl/ShopServiceImpl.java |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/server/dmmall_service/src/main/java/com/doumee/service/business/impl/ShopServiceImpl.java b/server/dmmall_service/src/main/java/com/doumee/service/business/impl/ShopServiceImpl.java
index d468a1c..0a5ea0a 100644
--- a/server/dmmall_service/src/main/java/com/doumee/service/business/impl/ShopServiceImpl.java
+++ b/server/dmmall_service/src/main/java/com/doumee/service/business/impl/ShopServiceImpl.java
@@ -206,6 +206,7 @@
         shop.setEditDate(new Date());
         shop.setIsdeleted(Constants.ONE);
         shopMapper.updateById(shop);
+        shopGoodsRelationMapper.delete(new UpdateWrapper<ShopGoodsRelation>().lambda().eq(ShopGoodsRelation::getShopId,id));
     }
 
     @Override
@@ -316,26 +317,27 @@
         queryWrapper.selectAll(Shop.class);
 
         queryWrapper.eq(Shop::getId,id);
-        queryWrapper.select("(select AVG(SCORE) from shop_comment where ISDELETED=0 and OBJ_ID=t.id) as score");//闂ㄥ簵璇勫垎
+//        queryWrapper.select("(select AVG(SCORE) from shop_comment where ISDELETED=0 and OBJ_ID=t.id) as score");//闂ㄥ簵璇勫垎
         /** ----------------start搴楅摵璁块棶鏁版嵁----------------*/
-        queryWrapper.select("(select count(id) from shop_scan where ISDELETED=0 and SHOP_ID=t.id) as shopTotalVisits");//涓婚〉鎬昏闂噺
-        queryWrapper.select("(select count(id) from shop_scan where ISDELETED=0 and SHOP_ID=t.id and to_days(CREATE_DATE)=to_days(now()) ) as shopNowVisits");//浠婃棩璁块棶閲�
-        queryWrapper.select("(select count(id) from shop_scan where ISDELETED=0 and SHOP_ID=t.id and to_days(CREATE_DATE)=to_days(DATE_SUB(CURDATE(), INTERVAL 1 DAY)) ) as shopYesterdayVisits");//鏄ㄦ棩鏃ヨ闂噺
-        queryWrapper.select("(select count(s.MEMBER_ID) from (select MEMBER_ID,SHOP_ID from shop_scan where ISDELETED=0   group by MEMBER_ID) as s where   s.SHOP_ID = t.id) as shopMemberVisits");//璁块棶鎬荤敤鎴锋暟
+//        queryWrapper.select("(select count(id) from shop_scan where ISDELETED=0 and SHOP_ID=t.id) as shopTotalVisits");//涓婚〉鎬昏闂噺
+//        queryWrapper.select("(select count(id) from shop_scan where ISDELETED=0 and SHOP_ID=t.id and to_days(CREATE_DATE)=to_days(now()) ) as shopNowVisits");//浠婃棩璁块棶閲�
+//        queryWrapper.select("(select count(id) from shop_scan where ISDELETED=0 and SHOP_ID=t.id and to_days(CREATE_DATE)=to_days(DATE_SUB(CURDATE(), INTERVAL 1 DAY)) ) as shopYesterdayVisits");//鏄ㄦ棩鏃ヨ闂噺
+//        queryWrapper.select("(select count(s.MEMBER_ID) from (select MEMBER_ID,SHOP_ID from shop_scan where ISDELETED=0   group by MEMBER_ID) as s where   s.SHOP_ID = t.id) as shopMemberVisits");//璁块棶鎬荤敤鎴锋暟
         /** ----------------end搴楅摵璁块棶鏁版嵁----------------*/
         /** ----------------start搴楅摵浜掑姩鏁版嵁----------------*/
-        queryWrapper.select("(select count(id) from shop_follow where ISDELETED=0 and OBJ_ID=t.id and OBJ_TYPE=0) as shopFollower");//绮変笣鏁�
-        queryWrapper.select("(select count(id) from shop_menu where ISDELETED=0 and SHOP_ID=t.id ) as shopMenu");//鑿滃搧鏁�
-        queryWrapper.select("(select count(id) from shop_comment where ISDELETED=0 and OBJ_ID=t.id ) as shopComment");//璇勮鏁�
-        queryWrapper.select("(select count(id) from shop_news where ISDELETED=0 and SHOP_ID=t.id ) as shopNews");//鏂伴矞浜�
+//        queryWrapper.select("(select count(id) from shop_follow where ISDELETED=0 and OBJ_ID=t.id and OBJ_TYPE=0) as shopFollower");//绮変笣鏁�
+//        queryWrapper.select("(select count(id) from shop_menu where ISDELETED=0 and SHOP_ID=t.id ) as shopMenu");//鑿滃搧鏁�
+//        queryWrapper.select("(select count(id) from shop_comment where ISDELETED=0 and OBJ_ID=t.id ) as shopComment");//璇勮鏁�
+//        queryWrapper.select("(select count(id) from shop_news where ISDELETED=0 and SHOP_ID=t.id ) as shopNews");//鏂伴矞浜�
         /** ----------------end搴楅摵浜掑姩鏁版嵁----------------*/
         /** ----------------start浼樻儬鍒告暟鎹�----------------*/
-        queryWrapper.select("(select count(id) from coupon where ISDELETED=0 and SHOP_ID=t.id and type=0) as couponCount");//浼樻儬鍒稿彂鏀炬�绘暟(寮�)
-        queryWrapper.select("(select count(id) from member_coupon where ISDELETED=0 and SHOP_ID=t.id and type=0) as couponDrawCount");//浼樻儬鍒搁鍙栨�绘暟(寮�)
-        queryWrapper.select("(select count(id) from member_coupon where ISDELETED=0 and SHOP_ID=t.id and type=0 and STATUS=1 ) as couponUserComment");//浼樻儬鍒镐娇鐢ㄦ�绘暟(寮�)
-        queryWrapper.select("(select sum(LIMIT_PRICE) from member_coupon where ISDELETED=0 and SHOP_ID=t.id and type=0 and STATUS=1 ) as couponUserMoney");//浼樻儬鍒镐娇鐢ㄩ噾棰�(鍏�)
+//        queryWrapper.select("(select count(id) from coupon where ISDELETED=0 and SHOP_ID=t.id and type=0) as couponCount");//浼樻儬鍒稿彂鏀炬�绘暟(寮�)
+//        queryWrapper.select("(select count(id) from member_coupon where ISDELETED=0 and SHOP_ID=t.id and type=0) as couponDrawCount");//浼樻儬鍒搁鍙栨�绘暟(寮�)
+//        queryWrapper.select("(select count(id) from member_coupon where ISDELETED=0 and SHOP_ID=t.id and type=0 and STATUS=1 ) as couponUserComment");//浼樻儬鍒镐娇鐢ㄦ�绘暟(寮�)
+//        queryWrapper.select("(select sum(LIMIT_PRICE) from member_coupon where ISDELETED=0 and SHOP_ID=t.id and type=0 and STATUS=1 ) as couponUserMoney");//浼樻儬鍒镐娇鐢ㄩ噾棰�(鍏�)
         /** ----------------end搴楅摵浼樻儬鍒告暟鎹�----------------*/
 
+        queryWrapper.select("(select count(g.id) from goodsorder g where g.ISDELETED=0 and  g.DISTRIBUTION_SHOP_ID=t.id ) as totalOrderNUm");//浼樻儬鍒镐娇鐢ㄩ噾棰�(鍏�)
        Shop shop= shopJoinMapper.selectJoinOne(Shop.class,queryWrapper);
         String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
                 + systemDictDataBiz.queryByCode(Constants.OSS, Constants.SHOP_FILE).getCode();
@@ -377,8 +379,9 @@
         queryWrapper.selectAll(Shop.class);
         if(pageWrap.getModel().getGoodsId()!=null){
             //鏌ヨ鏌愬晢鍝佺殑渚涜揣浠�
-            queryWrapper.select("(select s.price from shop_goods_relation s where s.ISDELETED=0 and s.shop_id = t.id and s.GOODS_ID="+pageWrap.getModel().getGoodsId()+") as goodsPrice ");
+            queryWrapper.select("(select s.price from shop_goods_relation s where s.ISDELETED=0 and s.shop_id = t.id and s.GOODS_ID="+pageWrap.getModel().getGoodsId()+" limit 1) as goodsPrice ");
         }
+        queryWrapper.select("(select count(s.id) from shop_goods_relation s left join goods g on s.goods_id =g.id where g.status=0 and s.ISDELETED=0 and s.shop_id=t.id) as pricedGoodsNum ");
         queryWrapper.selectAs(Labels::getName,Shop::getBigAreaName);
         queryWrapper.selectAs(Member::getNickname,Shop::getNickName);
         queryWrapper.selectAs(Member::getImgurl,Shop::getMemberImgurl);
@@ -401,9 +404,13 @@
         IPage<Shop> result = shopJoinMapper.selectJoinPage(page, Shop.class, queryWrapper);
         String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
                 + systemDictDataBiz.queryByCode(Constants.OSS, Constants.SHOP_FILE).getCode();
+        long goodsNum = goodsMapper.selectCount(new QueryWrapper<Goods>().lambda()
+                .eq(Goods::getIsdeleted,Constants.ZERO)
+                .eq(Goods::getStatus,Constants.ZERO));
         for(Shop model:result.getRecords()){
             model.setImgFullUrl(path);
             model.setAreas( AreasServiceImpl.getAddressByAreaId(model.getAreaId()));
+            model.setGoodsNum(goodsNum);
             if(model.getLatitude()!=null && model.getLongitude()!=null){
                 model.setLocationInfo(model.getLatitude().doubleValue()+","+model.getLongitude().doubleValue());
             }
@@ -803,7 +810,7 @@
 
 
     @Override
-    public SaleReportResponse saleReport(SaleReportRequest request,String shopId){
+    public SaleReportResponse saleReport(SaleReportRequest request,Integer shopId){
         SaleReportResponse saleReportResponse = new SaleReportResponse();
         saleReportResponse.setSaleTotal(BigDecimal.ZERO);
         saleReportResponse.setOrderNum(Constants.ZERO);
@@ -814,7 +821,6 @@
                         .selectAll(Goodsorder.class)
                         .selectAs(Member::getPhone,Goodsorder::getPhone)
                         .selectAs(Member::getNickname,Goodsorder::getNickName)
-                        .select(" select ifnull(sum(g.SHOP_SETTLEMENT),0) from goodsorder_detail g where t.id = g.ORDER_ID   ",Goodsorder::getShopSettlement)
                         .leftJoin(Member.class,Member::getId,Goodsorder::getMemberId)
                         .eq(Goodsorder::getIsdeleted,Constants.ZERO)
                         .eq(Goodsorder::getDistributionShopId,shopId)
@@ -876,12 +882,6 @@
         }
         return  saleReportResponse;
     }
-
-
-
-
-
-
 
     @Override
     @Transactional

--
Gitblit v1.9.3