doum
6 小时以前 666a942f5f2b59209cf422bb202f6548fbbe212e
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
@@ -222,15 +223,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)?"自由采购":"平台铺货");
        }
    }
@@ -320,9 +339,7 @@
       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());
@@ -392,6 +409,25 @@
            }
        }
        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 );
    }
@@ -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();