|
@@ -1,23 +1,216 @@
|
|
|
|
|
|
package io.platform.store.biz.service;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-
|
|
|
-import io.platform.store.biz.mapper.StoreAgentBrandLvMapper;
|
|
|
-import io.platform.store.biz.entity.StoreAgentBrandLv;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import com.alibaba.dubbo.common.utils.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+
|
|
|
+import io.platform.store.biz.entity.StoreAgentBrandLv;
|
|
|
+import io.platform.store.biz.entity.StoreBasicInfo;
|
|
|
+import io.platform.store.biz.mapper.StoreAgentBrandLvMapper;
|
|
|
+import io.platform.store.biz.mapper.StoreBasicInfoMapper;
|
|
|
|
|
|
@Service("storeAgentBrandLvService")
|
|
|
public class StoreAgentBrandLvService extends ServiceImpl<StoreAgentBrandLvMapper,StoreAgentBrandLv>{
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StoreBasicInfoMapper storeBasicInfoMapper;
|
|
|
+
|
|
|
public List<StoreAgentBrandLv> selectByMap(Map<String, Object> map) {
|
|
|
return baseMapper.selectByMap(map);
|
|
|
}
|
|
|
-
|
|
|
+ public IPage<StoreAgentBrandLv> getUncheckStoresByAgentId(Long size,Long current,String agentid){
|
|
|
+ IPage<StoreAgentBrandLv> page=new Page<StoreAgentBrandLv>(current, size);
|
|
|
+ QueryWrapper<StoreAgentBrandLv> wrapper=new QueryWrapper<StoreAgentBrandLv>();
|
|
|
+ wrapper.eq("agent_id", agentid);
|
|
|
+ wrapper.eq("AGENT_STATUS", "0");
|
|
|
+ wrapper.orderByDesc("CREATED_TIME");
|
|
|
+ IPage<StoreAgentBrandLv> result=baseMapper.selectPage(page, wrapper);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ public void UpdateStoreAgentStatus(String mainid,String status) {
|
|
|
+ QueryWrapper<StoreAgentBrandLv> wrapper=new QueryWrapper<StoreAgentBrandLv>();
|
|
|
+ wrapper.eq("MAIN_ID", mainid);
|
|
|
+ List<StoreAgentBrandLv> storeAgentBrandLvs=baseMapper.selectList(wrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(storeAgentBrandLvs)) {
|
|
|
+ StoreAgentBrandLv storeAgentBrandLv=storeAgentBrandLvs.get(0);
|
|
|
+ if (!"0".equals(storeAgentBrandLv.getAgentStatus())) {
|
|
|
+ throw new RuntimeException("数据状态异常,无法更改");
|
|
|
+ }
|
|
|
+ storeAgentBrandLv.setAgentStatus(status);
|
|
|
+ storeAgentBrandLv.setAgentOpDate(new Date());
|
|
|
+ baseMapper.updateById(storeAgentBrandLv);
|
|
|
+ }else {
|
|
|
+ throw new RuntimeException("数据不存在!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 在拒绝签约品牌任务的一条数据时判断此门店的签约品牌任务是否已经全部被拒绝并更改门店基础表的数据
|
|
|
+ * @Date:2020-11-9
|
|
|
+ * @Title: UpdateStoreStatus
|
|
|
+ * @Description: TODO(这里用一句话描述这个方法的作用)
|
|
|
+ * @param @param mainid 参数
|
|
|
+ * @return void 返回类型
|
|
|
+ * @throws
|
|
|
+ * @author jibin.wang
|
|
|
+ */
|
|
|
+ public void UpdateStoreStatus(String mainid) {
|
|
|
+ StoreAgentBrandLv storeAgentBrandLv=baseMapper.selectById(mainid);
|
|
|
+ if (storeAgentBrandLv!=null) {
|
|
|
+ Long storeid=storeAgentBrandLv.getStoreId();
|
|
|
+ if (storeid!=null) {
|
|
|
+ Set<String> agent_store_brandids=new HashSet<String>();
|
|
|
+ QueryWrapper<StoreAgentBrandLv> queryWrapper=new QueryWrapper<StoreAgentBrandLv>();
|
|
|
+ queryWrapper.eq("STORE_ID",storeid);
|
|
|
+ List<StoreAgentBrandLv> alllist=baseMapper.selectList(queryWrapper);
|
|
|
+ for (StoreAgentBrandLv entity : alllist) {
|
|
|
+ //去除重复数据()
|
|
|
+ String agent_store_brandid=entity.getStoreId()+","+entity.getAgentId()+","+entity.getBrandCode();
|
|
|
+ agent_store_brandids.add(agent_store_brandid);
|
|
|
+ //
|
|
|
+ }
|
|
|
+ Boolean canupdate=true;
|
|
|
+ for (String multid: agent_store_brandids) {
|
|
|
+ String [] multidarray=multid.split(",");
|
|
|
+ String eachstoreid=multidarray[0];
|
|
|
+ String eachagentid=multidarray[1];
|
|
|
+ String eachbrandcode=multidarray[2];
|
|
|
+ //
|
|
|
+ QueryWrapper<StoreAgentBrandLv> eachQueryWrapper=new QueryWrapper<StoreAgentBrandLv>();
|
|
|
+ eachQueryWrapper.eq("STORE_ID", eachstoreid);
|
|
|
+ eachQueryWrapper.eq("AGENT_ID", eachagentid);
|
|
|
+ eachQueryWrapper.eq("BRAND_CODE", eachbrandcode);
|
|
|
+ eachQueryWrapper.eq("AGENT_STATUS", "2");
|
|
|
+ Integer refushcount=baseMapper.selectCount(eachQueryWrapper);
|
|
|
+ //
|
|
|
+ QueryWrapper<StoreAgentBrandLv> AllQueryWrapper=new QueryWrapper<StoreAgentBrandLv>();
|
|
|
+ AllQueryWrapper.eq("STORE_ID", eachstoreid);
|
|
|
+ AllQueryWrapper.eq("AGENT_ID", eachagentid);
|
|
|
+ AllQueryWrapper.eq("BRAND_CODE", eachbrandcode);
|
|
|
+ Integer allcount=baseMapper.selectCount(AllQueryWrapper);
|
|
|
+ if (refushcount<allcount) {
|
|
|
+ canupdate=false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (canupdate) {
|
|
|
+ StoreBasicInfo basicInfo=storeBasicInfoMapper.selectById(storeid);
|
|
|
+ if (basicInfo!=null) {
|
|
|
+ basicInfo.setStatus(2L);
|
|
|
+ storeBasicInfoMapper.updateById(basicInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 根据门店id去签约表里判断这个门店是否需要更改门店基础信息表的状态
|
|
|
+ * @Date:2020-11-11
|
|
|
+ * @Title: updateStoreStatusBySignInfo
|
|
|
+ * @Description: TODO(这里用一句话描述这个方法的作用)
|
|
|
+ * @param @param storeid 参数
|
|
|
+ * @return void 返回类型
|
|
|
+ * @throws
|
|
|
+ */
|
|
|
+ public void updateStoreStatusBySignInfo(String storeid) {
|
|
|
+ //默认状态为未审核
|
|
|
+ String defaultstatus="0";
|
|
|
+ //去除重复数据
|
|
|
+ Set<String> agent_store_brandids=new HashSet<String>();
|
|
|
+ QueryWrapper<StoreAgentBrandLv> queryWrapper=new QueryWrapper<StoreAgentBrandLv>();
|
|
|
+ queryWrapper.eq("STORE_ID",storeid);
|
|
|
+ List<StoreAgentBrandLv> alllist=baseMapper.selectList(queryWrapper);
|
|
|
+ for (StoreAgentBrandLv entity : alllist) {
|
|
|
+ String agent_store_brandid=entity.getStoreId()+","+entity.getAgentId()+","+entity.getBrandCode();
|
|
|
+ agent_store_brandids.add(agent_store_brandid);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(agent_store_brandids)) {
|
|
|
+ //首先判断是否需要改为未审核状态
|
|
|
+ Boolean canupdaterefuse=true;
|
|
|
+ for (String multid: agent_store_brandids) {
|
|
|
+ String [] multidarray=multid.split(",");
|
|
|
+ String eachstoreid=multidarray[0];
|
|
|
+ String eachagentid=multidarray[1];
|
|
|
+ String eachbrandcode=multidarray[2];
|
|
|
+ //
|
|
|
+ QueryWrapper<StoreAgentBrandLv> eachQueryWrapper=new QueryWrapper<StoreAgentBrandLv>();
|
|
|
+ eachQueryWrapper.eq("STORE_ID", eachstoreid);
|
|
|
+ eachQueryWrapper.eq("AGENT_ID", eachagentid);
|
|
|
+ eachQueryWrapper.eq("BRAND_CODE", eachbrandcode);
|
|
|
+ eachQueryWrapper.eq("AGENT_STATUS", "2");
|
|
|
+ Integer refushcount=baseMapper.selectCount(eachQueryWrapper);
|
|
|
+ //
|
|
|
+ QueryWrapper<StoreAgentBrandLv> AllQueryWrapper=new QueryWrapper<StoreAgentBrandLv>();
|
|
|
+ AllQueryWrapper.eq("STORE_ID", eachstoreid);
|
|
|
+ AllQueryWrapper.eq("AGENT_ID", eachagentid);
|
|
|
+ AllQueryWrapper.eq("BRAND_CODE", eachbrandcode);
|
|
|
+ Integer allcount=baseMapper.selectCount(AllQueryWrapper);
|
|
|
+ if (refushcount<allcount) {
|
|
|
+ canupdaterefuse=false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (canupdaterefuse) {
|
|
|
+ defaultstatus="2";
|
|
|
+ }
|
|
|
+ //判断是否需要更改为审核通过状态
|
|
|
+ Boolean canupdatepass=true;
|
|
|
+ for (String multid: agent_store_brandids) {
|
|
|
+ String [] multidarray=multid.split(",");
|
|
|
+ String eachstoreid=multidarray[0];
|
|
|
+ String eachagentid=multidarray[1];
|
|
|
+ String eachbrandcode=multidarray[2];
|
|
|
+ //
|
|
|
+ QueryWrapper<StoreAgentBrandLv> eachQueryWrapper=new QueryWrapper<StoreAgentBrandLv>();
|
|
|
+ eachQueryWrapper.eq("STORE_ID", eachstoreid);
|
|
|
+ eachQueryWrapper.eq("AGENT_ID", eachagentid);
|
|
|
+ eachQueryWrapper.eq("BRAND_CODE", eachbrandcode);
|
|
|
+ eachQueryWrapper.eq("AGENT_STATUS", "1");
|
|
|
+ Integer passcount=baseMapper.selectCount(eachQueryWrapper);
|
|
|
+ if (passcount==0) {
|
|
|
+ canupdatepass=false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (canupdatepass) {
|
|
|
+ defaultstatus="1";
|
|
|
+ }
|
|
|
+ //更新状态
|
|
|
+ StoreBasicInfo basicInfo=storeBasicInfoMapper.selectById(storeid);
|
|
|
+ if (basicInfo!=null) {
|
|
|
+ basicInfo.setStatus(Long.parseLong(defaultstatus));
|
|
|
+ storeBasicInfoMapper.updateById(basicInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 经销商删除门店的品牌的签约
|
|
|
+ * @Date:2020-11-11
|
|
|
+ * @Title: deleteSignByAgentAndStoreAndBrand
|
|
|
+ * @Description: TODO(这里用一句话描述这个方法的作用)
|
|
|
+ * @param @param storeid
|
|
|
+ * @param @param agentid
|
|
|
+ * @param @param brandcode 参数
|
|
|
+ * @return void 返回类型
|
|
|
+ * @throws
|
|
|
+ */
|
|
|
+ public void deleteSignByAgentAndStoreAndBrand(String storeid,String agentid,String brandcode) {
|
|
|
+ QueryWrapper<StoreAgentBrandLv> queryWrapper=new QueryWrapper<StoreAgentBrandLv>();
|
|
|
+ queryWrapper.eq("STORE_ID", storeid);
|
|
|
+ queryWrapper.eq("AGENT_ID",agentid);
|
|
|
+ queryWrapper.eq("BRAND_CODE", brandcode);
|
|
|
+ baseMapper.delete(queryWrapper);
|
|
|
+ }
|
|
|
/**
|
|
|
* 根据门店id获取门店经营品牌集合
|
|
|
* @param storeId
|