From 4d2dda710968035fa52e69dea47525985674422b Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期三, 21 一月 2026 17:18:14 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 server/dmmall_service/src/main/java/com/doumee/service/business/impl/ShopServiceImpl.java |   98 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 67 insertions(+), 31 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 895268e..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
@@ -1,6 +1,6 @@
 package com.doumee.service.business.impl;
 
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.alibaba.fastjson.JSONObject;
 import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.config.Jwt.JwtPayLoad;
 import com.doumee.config.Jwt.JwtTokenUtil;
@@ -11,11 +11,11 @@
 import com.doumee.core.model.PageData;
 import com.doumee.core.model.PageWrap;
 import com.doumee.core.utils.Constants;
+import com.doumee.core.utils.DateUtil;
 import com.doumee.core.utils.Utils;
 import com.doumee.dao.business.*;
 import com.doumee.dao.business.join.GoodsorderJoinMapper;
 import com.doumee.dao.business.join.MemberJoinMapper;
-import com.doumee.dao.business.*;
 import com.doumee.dao.business.join.ProductLabelJoinMapper;
 import com.doumee.dao.business.model.*;
 import com.doumee.dao.business.model.Labels;
@@ -24,6 +24,7 @@
 import com.doumee.dao.business.model.ShopScan;
 import com.doumee.dao.system.SystemUserMapper;
 import com.doumee.dao.system.model.SystemUser;
+import com.doumee.dao.system.vo.ShopMoneyVO;
 import com.doumee.dao.web.dto.*;
 import com.doumee.dao.web.dto.shop.*;
 import com.doumee.dao.web.request.MyCustomerRequest;
@@ -39,12 +40,9 @@
 import org.apache.shiro.SecurityUtils;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.xpath.operations.Bool;
-import org.checkerframework.checker.units.qual.C;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -64,6 +62,9 @@
 
     @Autowired
     private ShopMapper shopMapper;
+    @Autowired
+    private UserActionMapper userActionMapper;
+
     @Autowired
     private GoodsMapper goodsMapper;
     @Autowired
@@ -205,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
@@ -222,15 +224,33 @@
     }
 
     @Override
+    @Transactional
     public void updateById(Shop shop) {
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         if(shop.getId()==null ){
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage());
         }
         isCreateParamValid(shop,user);
+        Shop model = shopMapper.selectById(shop.getId());
+        if(model.getId()==null || Constants.equalsInteger(model.getIsdeleted(),Constants.ONE) ){
+            throw new BusinessException(ResponseStatus.DATA_EMPTY);
+        }
         shop.setEditor(user.getId());
         shop.setEditDate(new Date());
+
         shopMapper.updateById(shop);
+        if(shop.getSaleType() !=null && !Constants.equalsInteger(shop.getSaleType(),model.getSaleType())){
+            //濡傛灉閿�鍞ā寮忓彂鐢熺紪鐮侊紝璁板綍鍙樻洿璁板綍
+            //鏇存崲鏃ュ織璁板綍
+            UserActionServiceImpl.saveUserActionBiz(user,shop.getId(),
+                    Constants.UserActionType.CHANGE_SALETYPE,
+                    userActionMapper,
+                    shop.getEditDate(),
+                    new String[]{user.getUsername(), DateUtil.getPlusTime2(shop.getEditDate())},
+                    JSONObject.toJSONString(shop) ,
+                    Constants.equalsInteger(model.getSaleType(),Constants.ONE)?"鑷敱閲囪喘":"骞冲彴閾鸿揣",
+                    Constants.equalsInteger(shop.getSaleType(),Constants.ONE)?"鑷敱閲囪喘":"骞冲彴閾鸿揣");
+        }
     }
 
 
@@ -297,32 +317,31 @@
         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();
-        if(Objects.nonNull(shop)&&StringUtils.isNotBlank(shop.getImgurl())){
-            shop.setImgFullUrl(path+shop.getImgurl());
-        }
+        shop.setImgFullUrl(path);
         shop.setAreas(AreasServiceImpl.getAddressByAreaId(shop.getAreaId()));
         if(shop.getLatitude()!=null && shop.getLongitude()!=null){
             shop.setLocationInfo(shop.getLatitude().doubleValue()+","+shop.getLongitude().doubleValue());
@@ -360,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);
@@ -384,14 +404,37 @@
         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());
             }
 
         }
+        return PageData.from(result );
+    }
+    @Override
+    public   PageData<ShopMoneyVO>  findPageMoney(PageWrap<Shop> pageWrap){
+        IPage<Shop> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
+        MPJLambdaWrapper<Shop> queryWrapper = new MPJLambdaWrapper<>();
+        Utils.MP.blankToNull(pageWrap.getModel());
+        queryWrapper
+                .selectAll(Shop.class)
+                .select("(select sum(price) from goodsorder g where  g.DISTRIBUTION_SHOP_ID=t.id and g.status in (1,2) and g.isdeleted=0) as jiesuanIng" )
+                .select("(select g.create_date from withdraw_record g where  g.MEMBER_ID=t.id  and g.isdeleted=0 order by g.id desc limit 1 ) as withdrawDate" )
+                .select("(select sum(g.amount)  from withdraw_record g where  g.MEMBER_ID=t.id and g.status=1  and g.isdeleted=0 ) as withdrawTotal"  )
+                .select("(select sum(g.amount)  from withdraw_record g where  g.MEMBER_ID=t.id and g.status=0 and g.isdeleted=0 ) as withdrawIng" );
+        queryWrapper.eq(Shop::getIsdeleted, Constants.ZERO);
+        queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getCode()) ,Shop::getCode,pageWrap.getModel().getCode());
+        queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getUsername()) ,Shop::getName,pageWrap.getModel().getUsername());
+        queryWrapper.like(StringUtils.isNotBlank(pageWrap.getModel().getName()) ,Shop::getName,pageWrap.getModel().getName());
+        queryWrapper.orderByDesc(Shop::getId);
+        IPage<ShopMoneyVO> result = shopJoinMapper.selectJoinPage(page, ShopMoneyVO.class, queryWrapper);
         return PageData.from(result );
     }
 
@@ -767,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);
@@ -778,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)
@@ -841,12 +883,6 @@
         return  saleReportResponse;
     }
 
-
-
-
-
-
-
     @Override
     @Transactional
     public  String setGoodsPrice(Shop dto){
@@ -864,7 +900,7 @@
         }
         //榛樿sku淇℃伅
         GoodsSku goodsSku = goodsSkuList.get(0);
-        if(Constants.formatBigdecimal(goodsSku.getPrice()).compareTo(Constants.formatBigdecimal(dto.getGoodsPrice())) >=0){
+        if(Constants.formatBigdecimal(goodsSku.getPrice()).compareTo(Constants.formatBigdecimal(dto.getGoodsPrice()))<=0){
             throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝渚涜揣浠蜂笉鍏佽澶т簬鍟嗗搧閿�鍞环锛�");
         }
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();

--
Gitblit v1.9.3