jiangqs
2023-06-11 962e7325d72222a4ffd4d74a1fc5612f95326e98
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
package com.ruoyi.shop.service.impl.shop;
 
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.shop.domain.dto.MerShopSuggestDto;
import com.ruoyi.shop.domain.dto.MgtReplayShopSuggestDto;
import com.ruoyi.shop.domain.dto.MgtShopSuggestPageDto;
import com.ruoyi.shop.domain.dto.MgtTagShopSuggestDto;
import com.ruoyi.shop.domain.pojo.shop.ShopSuggest;
import com.ruoyi.shop.domain.vo.MerShopSuggestVo;
import com.ruoyi.shop.domain.vo.MgtShopSuggestPageVo;
import com.ruoyi.shop.domain.vo.MgtShopSuggestTagVo;
import com.ruoyi.shop.mapper.shop.ShopSuggestMapper;
import com.ruoyi.shop.service.shop.ShopSuggestService;
import com.ruoyi.system.api.domain.dto.MerPageDto;
import com.ruoyi.system.api.domain.poji.config.SysTag;
import com.ruoyi.system.api.domain.poji.sys.SysUser;
import com.ruoyi.system.api.service.RemoteConfigService;
import com.ruoyi.system.api.service.RemoteUserService;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jqs
 * @since 2023-05-09
 */
@Service
public class ShopSuggestServiceImpl extends ServiceImpl<ShopSuggestMapper, ShopSuggest> implements ShopSuggestService {
 
    @Resource
    private ShopSuggestMapper shopSuggestMapper;
 
    @Resource
    private RemoteUserService remoteUserService;
 
    @Resource
    private RemoteConfigService remoteConfigService;
 
 
    /**
     *
     * @param page
     * @param merPageDto
     * @return
     */
    @Override
    public List<MerShopSuggestVo> pageMerShopSuggest(Page page, MerPageDto merPageDto){
        return shopSuggestMapper.pageMerShopSuggest(page, merPageDto);
    }
 
    /**
     * 建议
     * @param merShopSuggestDto
     */
    @Override
    public void suggest(MerShopSuggestDto merShopSuggestDto){
        ShopSuggest shopSuggest = new ShopSuggest();
        shopSuggest.setDelFlag(0);
        shopSuggest.setCreateUserId(merShopSuggestDto.getUserId());
        shopSuggest.setShopId(merShopSuggestDto.getShopId());
        shopSuggest.setSuggestContent(merShopSuggestDto.getSuggestContent());
        shopSuggest.setCreateTime(new Date());
        shopSuggest.setReplayFlag(0);
        this.save(shopSuggest);
    }
 
    /**
     * @description  删除商户建议标签
     * @author  jqs
     * @date    2023/6/9 10:18
     * @param suggestTag
     * @return  void
     */
    @Override
    public void deleteShopSuggestTag(String suggestTag){
        shopSuggestMapper.deleteShopSuggestTag(suggestTag);
    }
 
    /**
     * @description 平台获取商户建议列表
     * @param page
     * @param mgtShopSuggestPageDto
     * @return List<MgtShopSuggestPageVo>
     * @author jqs34
     * @date 2023/6/11 16:56
     */
    @Override
    public List<MgtShopSuggestPageVo> pageMgtShopSuggest(Page page, MgtShopSuggestPageDto mgtShopSuggestPageDto){
        //处理标签为正则方便sql判断
        if(StringUtils.isNotBlank(mgtShopSuggestPageDto.getTags())){
            mgtShopSuggestPageDto.setTags(mgtShopSuggestPageDto.getTags().replace(",","|"));
        }
        if(mgtShopSuggestPageDto.getSuggestStatus()!=null&&mgtShopSuggestPageDto.getSuggestStatus()!=1){
            mgtShopSuggestPageDto.setSuggestStatus(0);
        }
        //获取返回结果
        List<MgtShopSuggestPageVo> mgtShopSuggestPageVoList = shopSuggestMapper.pageMgtShopSuggest(page, mgtShopSuggestPageDto);
        return mgtShopSuggestPageVoList;
    }
 
    /**
     * @description 平台回复会员建议
     * @param mgtReplayShopSuggestDto
     * @return void
     * @author jqs34
     * @date 2023/6/11 17:09
     */
    @Override
    public void mgtReplayShopSuggest(MgtReplayShopSuggestDto mgtReplayShopSuggestDto){
        Long userId = mgtReplayShopSuggestDto.getUserId();
        SysUser sysUser = remoteUserService.getSysUser(userId).getData();
        ShopSuggest shopSuggest = this.getById(mgtReplayShopSuggestDto.getSuggestId());
        shopSuggest.setReplayContent(mgtReplayShopSuggestDto.getReplayContent());
        shopSuggest.setReplayTime(new Date());
        shopSuggest.setReplayUserId(userId);
        shopSuggest.setReplayUserName(sysUser.getNickName());
        shopSuggest.setReplayFlag(1);
        String responseTime = DateUtils.formatDuration(shopSuggest.getCreateTime(), shopSuggest.getReplayTime());
        shopSuggest.setResponseTime(responseTime);
        this.saveOrUpdate(shopSuggest);
    }
 
    /**
     * @description listMgtShopSuggestTag
     * @param suggestId
     * @return List<MgtShopSuggestTagVo>
     * @author jqs34
     * @date 2023/6/11 17:29
     */
    @Override
    public List<MgtShopSuggestTagVo> listMgtShopSuggestTag(Long suggestId){
        ShopSuggest shopSuggest = this.getById(suggestId);
        String suggestTags = shopSuggest.getSuggestTags();
        Long[] tagIdLongArr = null;
        if(StringUtils.isNotBlank(suggestTags)){
            String[] tagIdArr = suggestTags.split(",");
            tagIdLongArr = new Long[tagIdArr.length];
            for (int i = 0; i < tagIdArr.length; i++) {
                try {
                    tagIdLongArr[i] = Long.parseLong(tagIdArr[i]);
                } catch (NumberFormatException e) {
                    tagIdLongArr[i] = null;
                }
            }
        }
        List<SysTag> sysTagsList = remoteConfigService.listSysTag(4).getData();
        //生成返回结果
        List<MgtShopSuggestTagVo> mgtShopSuggestTagVoList = new ArrayList<>();
        for(SysTag sysTag : sysTagsList){
            MgtShopSuggestTagVo mgtShopSuggestTagVo = new MgtShopSuggestTagVo();
            mgtShopSuggestTagVo.setTagId(sysTag.getTagId());
            mgtShopSuggestTagVo.setTagName(sysTag.getTagName());
            //判断是否选择
            if(tagIdLongArr!=null && tagIdLongArr.length>0){
                for(Long tagId : tagIdLongArr){
                    if(tagId!=null && tagId.equals(sysTag.getTagId())){
                        mgtShopSuggestTagVo.setSelectFlag(1);
                        break;
                    }
                }
            }
            mgtShopSuggestTagVoList.add(mgtShopSuggestTagVo);
        }
        return mgtShopSuggestTagVoList;
    }
 
    /**
     * @description 平台编辑会员建议标签
     * @param mgtTagShopSuggestDto
     * @return void
     * @author jqs34
     * @date 2023/6/11 17:34
     */
    @Override
    public void mgtEditShopSuggestTag(MgtTagShopSuggestDto mgtTagShopSuggestDto){
        ShopSuggest shopSuggest = this.getById(mgtTagShopSuggestDto.getSuggestId());
        shopSuggest.setSuggestTags(mgtTagShopSuggestDto.getSuggestTags());
        this.saveOrUpdate(shopSuggest);
    }
}