mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
192
193
package com.panzhihua.service_community.service.impl;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.VolunteerMerchantVO;
import com.panzhihua.common.model.vos.community.VolunteerTypeVO;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_community.dao.VolunteerMerchantDao;
import com.panzhihua.service_community.dao.VolunteerTypeDao;
import com.panzhihua.service_community.entity.SysUser;
import com.panzhihua.service_community.entity.VolunteerActivity;
import com.panzhihua.service_community.entity.VolunteerMerchant;
import com.panzhihua.service_community.entity.VolunteerType;
import com.panzhihua.service_community.service.VolunteerIntegralMerchantService;
import com.panzhihua.service_community.service.VolunteerMerchantService;
import com.panzhihua.service_community.service.VolunteerTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
 
 
@Slf4j
@Service
public class VolunteerMerchantServiceImpl extends ServiceImpl<VolunteerMerchantDao,
        VolunteerMerchant> implements VolunteerMerchantService
{
    @Resource
    private VolunteerMerchantService vmService;
 
 
    @Resource
    private VolunteerIntegralMerchantService vimService;
 
    @Override
    public R getById(String id) {
        return R.ok(baseMapper.getById(id));
    }
 
    @Override
    public R volunteerMerchantGetList(int pageNum, int pageSize, String merchantState,
                                      String merchantType, String name, String communityId) {
        Page page=new Page<VolunteerMerchant>(pageNum,pageSize);
        return R.ok(baseMapper.getList(page, merchantState,merchantType,name,communityId));
    }
 
    @Override
    public R insertVolunteerMerchant(VolunteerMerchantVO vtvo)
    {
        if(vtvo==null)
        {
            return R.fail("参数不能为空");
        }
 
        if(StringUtils.isEmpty(vtvo.getName()))
        {
            return R.fail("商家姓名不能为空");
        }
 
        if(StringUtils.isEmpty(vtvo.getBusinessType()))
        {
            return R.fail("商家类型不能为空");
        }
 
        if(StringUtils.isEmpty(vtvo.getLogoUrl()))
        {
            return R.fail("商家logo封面不能为空");
        }
 
        if(StringUtils.isEmpty(vtvo.getAddress()))
        {
            return R.fail("商家地址不能为空");
        }
 
 
        if(StringUtils.isEmpty(vtvo.getLat()))
        {
            return R.fail("商家经纬度不能为空");
        }
 
 
        if(StringUtils.isEmpty(vtvo.getUserId()))
        {
            return R.fail("管理员不能为空");
        }
 
 
        if(vtvo.getBusinessStartTime()==null || vtvo.getBusinessEndTime()==null )
        {
            return R.fail("营业时间不能为空");
        }
 
 
        if(StringUtils.isEmpty(vtvo.getMerchantType()))
        {
            return R.fail("营业状态不能为空");
        }
 
 
        if(StringUtils.isEmpty(vtvo.getServiceCall()))
        {
            return R.fail("对外服务电话不能为空");
        }
 
        if(StringUtils.isEmpty(vtvo.getMerchantContent()))
        {
            return R.fail("商家简介不能为空");
        }
 
        if(StringUtils.isEmpty(vtvo.getMerchantUrl()))
        {
            return R.fail("商家图片不能为空");
        }
 
 
        if(StringUtils.isEmpty(vtvo.getLegalPersonName()))
        {
            return R.fail("法人代表不能为空");
        }
 
        if(StringUtils.isEmpty(vtvo.getLegalPersonPhone()))
        {
            return R.fail("法人联系电话不能为空");
        }
 
        if(StringUtils.isEmpty(vtvo.getLegalPersonIdCard()))
        {
            return R.fail("法人身份证不能为空");
        }
 
        R<String> isM=vmService.isMerchant(vtvo.getUserId());
 
        if(!StringUtils.isEmpty(isM.getData()))
        {
            return R.fail("已有商家!不能重复添加");
        }
 
        int num= baseMapper.insertData(vtvo);
        if(num>0)
        {
            return R.ok();
        }
        return R.fail("添加失败");
    }
 
    @Override
    public R updateVolunteerMerchant(VolunteerMerchantVO vtvo)
    {
        if(vtvo==null)
        {
            return R.fail("参数不能为空");
        }
        int num= baseMapper.Update(vtvo);
        if(num>0)
        {
            return R.ok();
        }
        return R.fail("添加失败");
    }
 
    @Override
    public R deleteVolunteerMerchant(String id)
    {
 
        int goodNum=vimService.getNum(id);
 
        if(goodNum>0)
        {
            return R.fail("请下架所有商铺商品");
        }
 
        int num= baseMapper.delete(id);
        if(num>0)
        {
            return R.ok();
        }
        return R.fail("失败");
    }
 
    @Override
    public R isMerchant(String userId) {
        return R.ok(baseMapper.isMerchant(userId));
    }
 
    @Override
    public R getUser(String communityId, String userName, String userPhone)
    {
        return R.ok(baseMapper.getUser(communityId,userName,userPhone));
    }
 
 
}