|
@@ -7,7 +7,10 @@ import com.caimei.model.dto.ShopSaveDto;
|
|
|
import com.caimei.model.po.CmBrandAuthFilePo;
|
|
|
import com.caimei.model.po.ShopInfoPo;
|
|
|
import com.caimei.model.po.UserPo;
|
|
|
-import com.caimei.model.vo.ShopVo;
|
|
|
+import com.caimei.model.vo.BrandVo;
|
|
|
+import com.caimei.model.vo.CountryVo;
|
|
|
+import com.caimei.model.vo.ShopFormVo;
|
|
|
+import com.caimei.model.vo.ShopListVo;
|
|
|
import com.caimei.service.ShopService;
|
|
|
import com.caimei.utils.AliyunSmsUtil;
|
|
|
import com.caimei.utils.CodeUtil;
|
|
@@ -17,7 +20,6 @@ import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
@@ -42,14 +44,12 @@ public class ShopServiceImpl implements ShopService {
|
|
|
private ShopMapper shopMapper;
|
|
|
@Resource
|
|
|
private UserMapper userMapper;
|
|
|
- @Value("${caimei.oldapi}")
|
|
|
- private String oldapi;
|
|
|
|
|
|
@Override
|
|
|
- public ResponseJson<PageInfo<ShopVo>> getShopList(String shopName, Integer shopType, Integer brandId, String mobile, String linkMan, Integer pageNum, Integer pageSize) {
|
|
|
+ public ResponseJson<PageInfo<ShopListVo>> getShopList(String shopName, Integer shopType, Integer brandId, String mobile, String linkMan, Integer pageNum, Integer pageSize) {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
- List<ShopVo> shopList = shopMapper.getShopList(shopName, shopType, brandId, mobile, linkMan);
|
|
|
- PageInfo<ShopVo> pageData = new PageInfo<>(shopList);
|
|
|
+ List<ShopListVo> shopList = shopMapper.getShopList(shopName, shopType, brandId, mobile, linkMan);
|
|
|
+ PageInfo<ShopListVo> pageData = new PageInfo<>(shopList);
|
|
|
return ResponseJson.success(pageData);
|
|
|
}
|
|
|
|
|
@@ -91,7 +91,6 @@ public class ShopServiceImpl implements ShopService {
|
|
|
|
|
|
@Override
|
|
|
public ResponseJson<Integer> uploadFile(Integer authUserId, MultipartFile file) {
|
|
|
- System.out.println(oldapi);
|
|
|
String fileAllName = file.getOriginalFilename();
|
|
|
String fileType = fileAllName.substring(fileAllName.lastIndexOf(".") + 1);
|
|
|
String fileName = file.getResource().getFilename();
|
|
@@ -135,7 +134,8 @@ public class ShopServiceImpl implements ShopService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void deleteFileByUserId(Integer authUserId) {
|
|
|
+ @Override
|
|
|
+ public void deleteFileByUserId(Integer authUserId) {
|
|
|
CmBrandAuthFilePo searchFile = new CmBrandAuthFilePo();
|
|
|
searchFile.setAuthUserId(authUserId);
|
|
|
CmBrandAuthFilePo oldFile = shopMapper.getStatementFile(searchFile);
|
|
@@ -155,8 +155,10 @@ public class ShopServiceImpl implements ShopService {
|
|
|
if (shopType == null) {
|
|
|
return ResponseJson.error("请选择供应商类型", null);
|
|
|
}
|
|
|
+ // 是否为添加操作
|
|
|
+ Boolean insertFlag = null == shopSaveDto.getAuthUserId();
|
|
|
// 更新品牌授权logo
|
|
|
- shopMapper.updateBrandAuthLogo(shopSaveDto.getBrandId());
|
|
|
+ shopMapper.updateBrandAuthLogo(shopSaveDto.getBrandId(),shopSaveDto.getBrandAuthLogo());
|
|
|
/*
|
|
|
组装供应商用户数据
|
|
|
*/
|
|
@@ -169,7 +171,7 @@ public class ShopServiceImpl implements ShopService {
|
|
|
shop.setLinkMan(shopSaveDto.getLinkMan());
|
|
|
// 供应商状态
|
|
|
shop.setStatus(shopSaveDto.getShopStatus());
|
|
|
- if (null == shopSaveDto.getAuthUserId()) {
|
|
|
+ if (insertFlag) {
|
|
|
// 用户身份:1管理员,2供应商
|
|
|
shop.setUserIdentity(2);
|
|
|
// 创建管理员id
|
|
@@ -177,16 +179,12 @@ public class ShopServiceImpl implements ShopService {
|
|
|
// 创建时间
|
|
|
shop.setCreateTime(new Date());
|
|
|
// 设置随机8位密码
|
|
|
- shop.setPassword(CodeUtil.generateCode(8));
|
|
|
- } else {
|
|
|
- shop.setAuthUserId(shopSaveDto.getAuthUserId());
|
|
|
- }
|
|
|
- /*
|
|
|
- 保存供应商用户
|
|
|
- */
|
|
|
- if (null == shopSaveDto.getAuthUserId()) {
|
|
|
+ shop.setPassword(Md5Util.md5(CodeUtil.generateCode(8)));
|
|
|
+ // 插入供应商用户
|
|
|
shopMapper.insertShop(shop);
|
|
|
} else {
|
|
|
+ shop.setAuthUserId(shopSaveDto.getAuthUserId());
|
|
|
+ // 更新供应商用户
|
|
|
shopMapper.updateShopByUserId(shop);
|
|
|
}
|
|
|
/*
|
|
@@ -208,21 +206,24 @@ public class ShopServiceImpl implements ShopService {
|
|
|
shopInfo.setStatementContent(shopSaveDto.getStatementContent());
|
|
|
} else if (2 == shopSaveDto.getStatementType()) {
|
|
|
// 声明链接
|
|
|
- shopInfo.setStatementlink(shopSaveDto.getStatementLink());
|
|
|
+ shopInfo.setStatementLink(shopSaveDto.getStatementLink());
|
|
|
} else if (3 == shopSaveDto.getStatementType()) {
|
|
|
// 声明图片
|
|
|
shopInfo.setStatementImage(shopSaveDto.getStatementImage());
|
|
|
}
|
|
|
if (4 == shopSaveDto.getStatementType()) {
|
|
|
- // 更新代理声明文件
|
|
|
- Integer statementFileId = shopSaveDto.getStatementFileId();
|
|
|
- shopMapper.updateFileUserId(statementFileId, shop.getAuthUserId());
|
|
|
- } else {
|
|
|
+ if (insertFlag){
|
|
|
+ // 更新代理声明文件
|
|
|
+ Integer statementFileId = shopSaveDto.getStatementFileId();
|
|
|
+ shopMapper.updateFileUserId(statementFileId, shop.getAuthUserId());
|
|
|
+ }
|
|
|
+ } else if (!insertFlag){
|
|
|
// 没有选择文件代理声明的情况下,若存在原来的文件,删除代理声明文件
|
|
|
deleteFileByUserId(shop.getAuthUserId());
|
|
|
}
|
|
|
}
|
|
|
- if (null == shopSaveDto.getAuthUserId()) {
|
|
|
+ // 保存供应商信息
|
|
|
+ if (insertFlag) {
|
|
|
shopMapper.insertShopInfo(shopInfo);
|
|
|
} else {
|
|
|
shopMapper.updateShopInfoByUserId(shopInfo);
|
|
@@ -230,13 +231,24 @@ public class ShopServiceImpl implements ShopService {
|
|
|
return ResponseJson.success("保存供应商成功", null);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
- public ResponseJson<ShopVo> getShopFormData(Integer authUserId) {
|
|
|
+ public ResponseJson<ShopFormVo> getShopFormData(Integer authUserId) {
|
|
|
if (null == authUserId) {
|
|
|
return ResponseJson.error("参数异常,请输入供应商用户id", null);
|
|
|
}
|
|
|
- shopMapper.getShopByAuthUserId(authUserId);
|
|
|
- return null;
|
|
|
+ ShopFormVo shopForm = shopMapper.getShopByAuthUserId(authUserId);
|
|
|
+ return ResponseJson.success(shopForm);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<List<BrandVo>> getBrandList(Integer type) {
|
|
|
+ List<BrandVo> brandList = shopMapper.getBrandList(type);
|
|
|
+ return ResponseJson.success(brandList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseJson<List<CountryVo>> getCountryList() {
|
|
|
+ List<CountryVo> countryList = shopMapper.getCountryList();
|
|
|
+ return ResponseJson.success(countryList);
|
|
|
}
|
|
|
}
|