jiangqs
2023-05-26 aed4e4c7d76de4d0fbfe8c0b26fcdeecbd5c5b24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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.bean.BeanUtils;
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.domain.dto.MerEditUserDto;
import com.ruoyi.system.api.domain.poji.shop.Shop;
import com.ruoyi.system.api.domain.vo.MerStaffInfoVo;
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 ShopService shopService;
 
    @Resource
    private ShopRelUserService shopRelUserService;
 
    @Resource
    private ShopStaffMapper shopStaffMapper;
 
    /**
     *
     * @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){
        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());
 
        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);
    }
 
    /**
     * 清空商户员工关联
     * @param shopId
     */
    @Override
    public void clearShopStaffRelation(Long shopId){
        shopStaffMapper.clearShopStaffRelation(shopId);
    }
}