xuhy
2025-01-09 712f70b2936079a131ecb1e63c6d337171618cad
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
package com.stylefeng.guns.modular.system.service.impl;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.modular.system.dao.MerchantMapper;
import com.stylefeng.guns.modular.system.model.Merchant;
import com.stylefeng.guns.modular.system.service.IMerchantService;
import com.stylefeng.guns.modular.system.service.ISystemNoticeService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.warpper.MerchantWapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Date;
 
@Service
public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> implements IMerchantService {
 
    @Autowired
    private ISystemNoticeService systemNoticeService;
 
    @Override
    public ResultUtil registeredMerchant(Integer uid, String name, String headImg, String contactName, String contactPhone, String address, String businessLicense) throws Exception {
        Merchant merchant = this.selectOne(new EntityWrapper<Merchant>().eq("userType", 2).eq("userId", uid).ne("state", 3).ne("auditStatus", 3));
        if(null != merchant && merchant.getAuditStatus() == 1){
            return ResultUtil.error("不允许重复提交申请");
        }
        if(null != merchant && merchant.getAuditStatus() == 2){
            return ResultUtil.error("您已经是商家了");
        }
        if(null != merchant && merchant.getState() == 2){
            return ResultUtil.error("您的账号已被冻结,请联系客服");
        }
        merchant = this.selectOne(new EntityWrapper<Merchant>().eq("userType", 2).eq("userId", uid).ne("state", 3));
        if(null == merchant){
            merchant = new Merchant();
            merchant.setUserId(uid);
            merchant.setUserType(2);
            merchant.setName(name);
            merchant.setHeadImg(headImg);
            merchant.setContactName(contactName);
            merchant.setContactPhone(contactPhone);
            merchant.setAddress(address);
            merchant.setBusinessLicense(businessLicense);
            merchant.setAuditStatus(1);
            merchant.setState(1);
            merchant.setCreateTime(new Date());
            this.insert(merchant);
            systemNoticeService.addSystemNotice(2, "您已成功提交商家申请,我们会尽快进行审核", uid, 3);
        }else{
            merchant.setName(name);
            merchant.setHeadImg(headImg);
            merchant.setContactName(contactName);
            merchant.setContactPhone(contactPhone);
            merchant.setAddress(address);
            merchant.setBusinessLicense(businessLicense);
            merchant.setAuditStatus(1);
            merchant.setAuditNote("");
            merchant.setAuditTime(null);
            merchant.setAuditUserId(null);
            this.updateAllColumnById(merchant);
        }
        return ResultUtil.success();
    }
 
    @Override
    public MerchantWapper getMerchant(Integer uid) throws Exception {
        Merchant merchant = this.selectOne(new EntityWrapper<Merchant>().eq("userType", 2).eq("userId", uid).ne("state", 3));
        MerchantWapper merchantWapper = new MerchantWapper();
        if(null != merchant){
            BeanUtils.copyProperties(merchant, merchantWapper);
        }
        return merchantWapper;
    }
}