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", 1).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", 1).eq("userId", uid).ne("state", 3));
|
if(null == merchant){
|
merchant = new Merchant();
|
merchant.setUserId(uid);
|
merchant.setUserType(1);
|
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(1, "您已成功提交商家申请,我们会尽快进行审核", 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", 1).eq("userId", uid).ne("state", 3));
|
MerchantWapper merchantWapper = new MerchantWapper();
|
if(null != merchant){
|
BeanUtils.copyProperties(merchant, merchantWapper);
|
}
|
return merchantWapper;
|
}
|
}
|