package com.ruoyi.shop.service.impl.shop;
|
|
|
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.ShopStaff;
|
import com.ruoyi.shop.mapper.shop.ShopStaffMapper;
|
import com.ruoyi.shop.service.shop.ShopStaffService;
|
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.dto.MgtShopStaffEditDto;
|
import com.ruoyi.system.api.domain.poji.shop.Shop;
|
import com.ruoyi.system.api.domain.vo.MerStaffInfoVo;
|
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;
|
|
/**
|
* <p>
|
* 服务实现类
|
* </p>
|
*
|
* @author jqs
|
* @since 2023-05-09
|
*/
|
@Service
|
public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff> implements ShopStaffService {
|
|
|
@Resource
|
private ShopStaffMapper shopStaffMapper;
|
|
@Resource
|
private RemoteUserService remoteUserService;
|
|
@Resource
|
private RemoteSysStaffService remoteSysStaffService;
|
|
@Resource
|
private RemoteFileService remoteFileService;
|
/**
|
*
|
* @param userId
|
* @return
|
*/
|
@Override
|
public ShopStaff getByUserId(Long userId){
|
LambdaQueryWrapper<ShopStaff> queryWrapper = Wrappers.lambdaQuery();
|
queryWrapper.eq(ShopStaff::getDelFlag, 0).eq(ShopStaff::getUserId, userId);
|
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);
|
}
|
|
|
/**
|
* 获取商户员工信息
|
* @param userId
|
* @return
|
*/
|
@Override
|
public MerStaffInfoVo getShopStaffInfo(Long userId,Shop shop){
|
MerStaffInfoVo merStaffInfoVo = new MerStaffInfoVo();
|
ShopStaff shopStaff = this.getByUserId(userId);
|
BeanUtils.copyProperties(shopStaff,merStaffInfoVo);
|
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?shopId="+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
|
public void editShopStaffInfo(MerEditUserDto merEditUserDto){
|
ShopStaff shopStaff = this.getByUserId(merEditUserDto.getUserId());
|
Integer editType = merEditUserDto.getEditType();
|
switch (editType){
|
case 1:
|
shopStaff.setStaffName(merEditUserDto.getEditValue());
|
break;
|
case 2:
|
shopStaff.setStaffAvatar(merEditUserDto.getEditValue());
|
break;
|
case 3:
|
shopStaff.setStaffGender(Integer.valueOf(merEditUserDto.getEditValue()));
|
break;
|
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);
|
}
|
}
|
}
|