Commit ff6d776f by zhiwj

添加门店对外api

parent 884bb044
package com.gic.store.dto.open;
import java.io.Serializable;
/**
* @author zhiwj
* @Description:
* @date 2020-02-26 17:34
*/
public class StoreOpenDTO implements Serializable {
private static final long serialVersionUID = 7134994873372842837L;
private Integer enterpriseId;
/**
* 门店名称
*/
private String storeName;
/**
* 门店code
*/
private String storeCode;
/**
* 域id
*/
private Integer regionId;
/**
* 门店照片
*/
private String photos;
/**
* erp门店状态
*/
private Integer erpStatus;
/**
* 门店电话
*/
private String conactsPhone;
/**
* 营业天
*/
private String businessDay;
/**
* 营业时间
*/
private String businessTimes;
/**
* 门店分组名
*/
private String groupName;
/**
* 店招品牌
*/
private String brand;
/**
* 省
*/
private String province;
/**
* 市
*/
private String city;
/**
* 区县
*/
private String county;
/**
* 门店详细地址
*/
private String address;
/**
* 经度
*/
private String longitude;
/**
* 维度
*/
private String latitude;
/**
* 扩展字段
*/
private String expand;
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getStoreCode() {
return storeCode;
}
public void setStoreCode(String storeCode) {
this.storeCode = storeCode;
}
public Integer getRegionId() {
return regionId;
}
public void setRegionId(Integer regionId) {
this.regionId = regionId;
}
public String getPhotos() {
return photos;
}
public void setPhotos(String photos) {
this.photos = photos;
}
public Integer getErpStatus() {
return erpStatus;
}
public void setErpStatus(Integer erpStatus) {
this.erpStatus = erpStatus;
}
public String getConactsPhone() {
return conactsPhone;
}
public void setConactsPhone(String conactsPhone) {
this.conactsPhone = conactsPhone;
}
public String getBusinessDay() {
return businessDay;
}
public void setBusinessDay(String businessDay) {
this.businessDay = businessDay;
}
public String getBusinessTimes() {
return businessTimes;
}
public void setBusinessTimes(String businessTimes) {
this.businessTimes = businessTimes;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getExpand() {
return expand;
}
public void setExpand(String expand) {
this.expand = expand;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getCounty() {
return county;
}
public void setCounty(String county) {
this.county = county;
}
}
......@@ -2,6 +2,7 @@ package com.gic.store.service;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.store.dto.open.ClerkDTO;
import com.gic.store.dto.open.StoreOpenDTO;
import com.gic.store.dto.open.TestDTO;
/**
......@@ -37,6 +38,44 @@ public interface StoreOpenApiService {
ServiceResponse<String> getStoreDetail(Integer enterpriseId, String storeCode, Integer regionId);
/**
* 门店新增接口
* @Title: addStore
* @Description:
* @author zhiwj
* @param enterpriseId
* @param storeOpenDTO
* @return com.gic.api.base.commons.ServiceResponse<java.lang.String>
* @throws
*/
ServiceResponse<String> addStore(Integer enterpriseId, StoreOpenDTO storeOpenDTO);
/**
* 门店修改接口
* @Title: editStore
* @Description:
* @author zhiwj
* @param enterpriseId
* @param storeOpenDTO
* @return com.gic.api.base.commons.ServiceResponse<java.lang.String>
* @throws
*/
ServiceResponse<String> editStore(Integer enterpriseId, StoreOpenDTO storeOpenDTO);
/**
* 门店列表接口
* @Title: pageStore
* @Description:
* @author zhiwj
* @param enterpriseId
* @param regionId
* @return com.gic.api.base.commons.ServiceResponse<java.lang.String>
* @throws
*/
ServiceResponse<String> pageStore(Integer enterpriseId, Integer regionId);
/**
* 查询导购详情
* @Title: getClerkDetail

* @Description:
......
package com.gic.store.service.outer.impl;
import java.util.List;
import com.gic.api.base.commons.Page;
import com.gic.store.dto.ClerkSearchDTO;
import com.gic.store.dto.ClerkStoreListDTO;
import com.gic.store.dto.StoreSearchDTO;
import com.gic.store.dto.open.TestDTO;
import com.gic.store.service.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.constants.Constants;
......@@ -26,10 +12,23 @@ import com.gic.erp.operation.api.dto.ApiFieldDTO;
import com.gic.erp.operation.api.service.ApiFieldApiService;
import com.gic.gateway.sdk.anno.GatewayExporter;
import com.gic.gateway.sdk.anno.GatewayParams;
import com.gic.store.dto.StoreDTO;
import com.gic.store.dto.*;
import com.gic.store.dto.open.ClerkDTO;
import com.gic.store.dto.open.ClerkDetailDTO;
import com.gic.store.dto.open.StoreOpenDTO;
import com.gic.store.dto.open.TestDTO;
import com.gic.store.entity.TabClerk;
import com.gic.store.entity.TabStoreBrand;
import com.gic.store.entity.TabStoreGroup;
import com.gic.store.service.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("storeOpenApiService")
@GatewayExporter
......@@ -47,6 +46,12 @@ public class StoreOpenApiServiceImpl implements StoreOpenApiService {
private ClerkApiService clerkApiService;
@Autowired
private StoreApiService storeApiService;
@Autowired
private StoreGroupService storeGroupService;
@Autowired
private StoreBrandService storeBrandService;
@Autowired
private ProvincesApiService provincesApiService;
@Override
public ServiceResponse<String> getApiFieldJson(Integer enterpriseId, Integer regionId) {
......@@ -83,6 +88,87 @@ public class StoreOpenApiServiceImpl implements StoreOpenApiService {
}
@Override
public ServiceResponse<String> addStore(Integer enterpriseId, StoreOpenDTO storeOpenDTO) {
LOGGER.info("对外API新增门店参数:{}", JSON.toJSONString(storeOpenDTO));
ServiceResponse<EnterpriseDTO> enterpriseResult = enterpriseApiService.getEnterpriseById(enterpriseId);
if (!enterpriseResult.isSuccess()) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "商户ID错误,无此商户");
}
StoreDTO storeDTO = EntityUtil.changeEntityByJSON(StoreDTO.class, storeOpenDTO);
if (StringUtils.isBlank(storeOpenDTO.getStoreName())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店名称不能为空");
}
if (StringUtils.isBlank(storeOpenDTO.getStoreCode())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店code不能为空");
}
if (storeOpenDTO.getRegionId() == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店域不能为空");
}
if (StringUtils.isNotBlank(storeOpenDTO.getBrand())) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "店招品牌不能为空");
}
// todo 校验门店类型
// todo 校验门店状态
if (StringUtils.isNotBlank(storeOpenDTO.getGroupName())) {
TabStoreGroup group = storeGroupService.getStoreGroupByName(storeOpenDTO.getGroupName(), enterpriseId);
if (group == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "门店分组不存在");
} else {
storeDTO.setStoreGroupId(group.getStoreGroupId());
}
}
TabStoreBrand brand = storeBrandService.getByStoreBrandName(enterpriseId, storeOpenDTO.getBrand());
if (brand == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "店招品牌不存在");
}
storeDTO.setBrandIds(brand.getStoreBrandId().toString());
if(StringUtils.isNotBlank(storeOpenDTO.getProvince()) && StringUtils.isNotBlank(storeOpenDTO.getCity()) && StringUtils.isNotBlank(storeOpenDTO.getCounty())) {
ServiceResponse<List<ProvinceDTO>> provinceResponse = provincesApiService.selectAllProvince();
ServiceResponse<List<CityDTO>> cityResponse = provincesApiService.selectAllCity();
ServiceResponse<List<CountyDTO>> countyResponse = provincesApiService.selectAllCounty();
List<ProvinceDTO> provinceDTOList = provinceResponse.getResult();
String finalProvince = storeOpenDTO.getProvince();
long provinceCount = provinceDTOList.stream().filter(e -> StringUtils.equals(e.getProvinceName(), finalProvince)).count();
List<CityDTO> cityDTOList = cityResponse.getResult();
String finalCity = storeOpenDTO.getCity();
long cityCount = cityDTOList.stream().filter(e -> StringUtils.equals(e.getCityName(), finalCity)).count();
List<CountyDTO> countyDTOList = countyResponse.getResult();
String finalCounty = storeOpenDTO.getCounty();
long countyCount = countyDTOList.stream().filter(e -> StringUtils.equals(e.getCountyName(), finalCounty)).count();
if (countyCount == 0) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "输入的区县信息有误");
}
if (cityCount == 0) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "输入的市信息有误");
}
if (provinceCount == 0) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "输入的省信息有误");
}
}
// todo 营业天
// todo 营业时间
// todo 自定义属性
return null;
}
@Override
public ServiceResponse<String> editStore(Integer enterpriseId, StoreOpenDTO storeOpenDTO) {
return null;
}
@Override
public ServiceResponse<String> pageStore(Integer enterpriseId, Integer regionId) {
return null;
}
@Override
@GatewayParams(query = {"enterpriseId", "storeCode", "clerkCode", "regionId"})
public ServiceResponse<String> getClerkDetail(Integer enterpriseId, String storeCode, String clerkCode, Integer regionId) {
//参数校验
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment