bug
jiangqs
2023-08-31 dbff53150cdc807faa56c0d1a947d24b69f372b9
ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopStaffServiceImpl.java
@@ -4,20 +4,20 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.bean.BeanUtils;
import com.ruoyi.shop.domain.pojo.shop.ShopRelTag;
import com.ruoyi.shop.domain.pojo.shop.ShopRelUser;
import com.ruoyi.shop.domain.pojo.shop.ShopStaff;
import com.ruoyi.shop.mapper.shop.ShopStaffMapper;
import com.ruoyi.shop.service.shop.ShopRelUserService;
import com.ruoyi.shop.service.shop.ShopService;
import com.ruoyi.shop.service.shop.ShopStaffService;
import com.ruoyi.system.api.RemoteMemberService;
import com.ruoyi.system.api.domain.dto.AppEditUserDto;
import com.ruoyi.system.api.domain.dto.CodeGetDto;
import com.ruoyi.system.api.domain.dto.MerEditUserDto;
import com.ruoyi.system.api.domain.poji.member.Member;
import com.ruoyi.system.api.domain.dto.MgtShopStaffEditDto;
import com.ruoyi.system.api.domain.poji.shop.Shop;
import com.ruoyi.system.api.domain.vo.MerStaffInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.system.api.service.RemoteFileService;
import com.ruoyi.system.api.service.RemoteSysStaffService;
import com.ruoyi.system.api.service.RemoteUserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -33,11 +33,18 @@
@Service
public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff> implements ShopStaffService {
    @Resource
    private ShopService shopService;
    @Resource
    private ShopRelUserService shopRelUserService;
    private ShopStaffMapper shopStaffMapper;
    @Resource
    private RemoteUserService remoteUserService;
    @Resource
    private RemoteSysStaffService remoteSysStaffService;
    @Resource
    private RemoteFileService remoteFileService;
    /**
     *
     * @param userId
@@ -50,6 +57,18 @@
        return this.getOne(queryWrapper,false);
    }
    /**
     * 通过手机号获取商户员工
     * @param mobile
     * @return
     */
    @Override
    public ShopStaff getByMobile(String mobile){
        LambdaQueryWrapper<ShopStaff> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(ShopStaff::getDelFlag, 0).eq(ShopStaff::getStaffMobile, mobile);
        return this.getOne(queryWrapper,false);
    }
    /**
     * 获取商户员工信息
@@ -57,22 +76,32 @@
     * @return
     */
    @Override
    public MerStaffInfoVo getShopStaffInfo(Long userId){
    public MerStaffInfoVo getShopStaffInfo(Long userId,Shop shop){
        MerStaffInfoVo merStaffInfoVo = new MerStaffInfoVo();
        ShopStaff shopStaff = this.getByUserId(userId);
        BeanUtils.copyProperties(shopStaff,merStaffInfoVo);
        ShopRelUser shopRelUser = shopRelUserService.getByUserId(userId);
        Shop shop = shopService.getByShopId(shopRelUser.getShopId());
        merStaffInfoVo.setShopName(shop.getShopName());
        merStaffInfoVo.setShopAddress(shop.getShopAddress());
        merStaffInfoVo.setShopServicePhone(shop.getShopServicePhone());
        merStaffInfoVo.setBusinessTime(shop.getBusinessStartTime()+"-"+shop.getBusinessEndTime());
        merStaffInfoVo.setShopType(shop.getShopType());
        merStaffInfoVo.setShopNumber(shop.getShopNumber());
        if(StringUtils.isNotBlank(shop.getShopCode())){
            merStaffInfoVo.setShopCodeUrl(shop.getShopCode());
        }else{
            CodeGetDto codeGetDto = new CodeGetDto();
            String url = "https://wxapp.hhhrt.cn/mini/shop?id="+shop.getShopId();
            codeGetDto.setUrl(url);
            codeGetDto.setFileName("shop-"+shop.getShopId());
            String codeUrl = remoteFileService.getAppOrderTotal(codeGetDto).getData();
            merStaffInfoVo.setShopCodeUrl(codeUrl);
            shopStaffMapper.updateShopCodeUrl(shop.getShopId(),codeUrl);
        }
        return merStaffInfoVo;
    }
    /**
     *
     * 编辑商户员工信息
     * @param merEditUserDto
     */
    @Override
@@ -92,7 +121,50 @@
            case 4:
                shopStaff.setStaffBirthday(merEditUserDto.getEditValue());
                break;
            default:
                break;
        }
        this.saveOrUpdate(shopStaff);
        //同步修改系统用户表
        AppEditUserDto appEditUserDto = new AppEditUserDto();
        appEditUserDto.setEditType(merEditUserDto.getEditType());
        appEditUserDto.setEditValue(merEditUserDto.getEditValue());
        appEditUserDto.setUserId(merEditUserDto.getUserId());
        remoteUserService.editUserInfo(appEditUserDto);
        //同步修改平台员工表
        remoteSysStaffService.editUserInfo(merEditUserDto);
    }
    /**
     * 清空商户员工关联
     * @param shopId
     */
    @Override
    public void clearShopStaffRelation(Long shopId){
        shopStaffMapper.clearShopStaffRelation(shopId);
    }
    /**
     * @description  修改商户员工信息
     * @author  jqs
     * @date    2023/7/19 19:03
     * @param mgtShopStaffEditDto
     * @return  void
     */
    @Override
    public void editMgtShopStaff(MgtShopStaffEditDto mgtShopStaffEditDto){
        ShopStaff shopStaff = this.getByUserId(mgtShopStaffEditDto.getUserId());
        if(shopStaff!=null){
            if(StringUtils.isNotBlank(mgtShopStaffEditDto.getStaffName())){
                shopStaff.setStaffName(mgtShopStaffEditDto.getStaffName());
            }
            if(StringUtils.isNotBlank(mgtShopStaffEditDto.getStaffMobile())){
                shopStaff.setStaffMobile(mgtShopStaffEditDto.getStaffMobile());
            }
            if(StringUtils.isNotBlank(mgtShopStaffEditDto.getStaffAvatar())){
                shopStaff.setStaffAvatar(mgtShopStaffEditDto.getStaffAvatar());
            }
            this.saveOrUpdate(shopStaff);
        }
    }
}