bug
jiangqs
2023-08-08 2d20929b57b4562959f355d20a09a474d46939dd
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
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);
        }
    }
}