添加了总部审核商家入驻信息(通过)的代码模块

This commit is contained in:
XinYi Song 2021-12-20 14:35:58 +08:00
parent a7b62f9fa8
commit 411ac03e85
4 changed files with 118 additions and 4 deletions

View File

@ -117,4 +117,19 @@ public class MerchantSettlementController {
String businessName = (String) map.get("businessName"); String businessName = (String) map.get("businessName");
return merchantSettlementService.selectAllBusiness(businessCity,businessCountry,businessName); return merchantSettlementService.selectAllBusiness(businessCity,businessCountry,businessName);
} }
/**
* 对商家入驻进行审核通过
* @param map
* @return
*/
@PostMapping("/updatePassBusiness")
public String updatePassBusiness(@RequestBody Map map){
Integer id = (Integer) map.get("id");
String username = (String) map.get("username");
String province = (String) map.get("province");
String city = (String) map.get("city");
String county = (String) map.get("county");
return merchantSettlementService.updatePassBusiness(id,username,province,city,county);
}
} }

View File

@ -3,6 +3,8 @@ package com.xkrs.dao;
import com.xkrs.model.entity.BusinessEntity; import com.xkrs.model.entity.BusinessEntity;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.util.List; import java.util.List;
@ -64,4 +66,30 @@ public interface BusinessDao extends JpaRepository<BusinessEntity,Long>, JpaSpec
* @return * @return
*/ */
BusinessEntity findByBusinessIdAndBusinessType(Integer id,String businessType); BusinessEntity findByBusinessIdAndBusinessType(Integer id,String businessType);
/**
* 对商家入驻进行审核1审核通过 2审核不通过
* @param id
* @param
*/
@Modifying(clearAutomatically=true)
@Query(value = "update business set business_type = '1' where id = ?1",nativeQuery = true)
void updatePassBusiness(Integer id);
/**
* 商家入驻审核不通过
* @param id
*/
@Modifying(clearAutomatically=true)
@Query(value = "update business set business_type = '2' where id = ?1",nativeQuery = true)
void updateNotPassBusiness(Integer id);
/**
* 根据商家id查询商家信息
* @param id
* @return
*/
BusinessEntity findById(Integer id);
} }

View File

@ -56,4 +56,12 @@ public interface MerchantSettlementService {
* @return * @return
*/ */
String selectAllBusiness(String businessCity, String businessCountry, String businessName); String selectAllBusiness(String businessCity, String businessCountry, String businessName);
/**
* 对商家入驻进行审核1审核通过 2审核不通过
* @param id
* @param
* @return
*/
String updatePassBusiness(Integer id,String username,String province,String city,String county);
} }

View File

@ -1,10 +1,8 @@
package com.xkrs.service.impl; package com.xkrs.service.impl;
import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.dao.BankCardDao; import com.xkrs.dao.*;
import com.xkrs.dao.BusinessDao; import com.xkrs.model.entity.*;
import com.xkrs.model.entity.BankCardEntity;
import com.xkrs.model.entity.BusinessEntity;
import com.xkrs.model.qo.BankCardQo; import com.xkrs.model.qo.BankCardQo;
import com.xkrs.model.qo.BusinessQo; import com.xkrs.model.qo.BusinessQo;
import com.xkrs.service.MerchantSettlementService; import com.xkrs.service.MerchantSettlementService;
@ -13,10 +11,12 @@ import com.xkrs.utils.PhotoUtil;
import com.xkrs.utils.Query; import com.xkrs.utils.Query;
import com.xkrs.utils.VerifyBankCardUtil; import com.xkrs.utils.VerifyBankCardUtil;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.security.crypto.keygen.KeyGenerators;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@ -24,6 +24,8 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
import static com.xkrs.utils.DateTimeUtil.getNowTime;
import static com.xkrs.utils.EncryptDecryptUtil.encry256;
/** /**
* @Author: XinYi Song * @Author: XinYi Song
@ -42,6 +44,15 @@ public class MerchantSettlementServiceImpl implements MerchantSettlementService
@Resource @Resource
private Query query; private Query query;
@Resource
private SysUserDao sysUserDao;
@Resource
private RelUserRoleDao relUserRoleDao;
@Resource
private RelRoleAuthorityDao relRoleAuthorityDao;
/** /**
* 商家入驻 * 商家入驻
* @param businessQo * @param businessQo
@ -149,4 +160,56 @@ public class MerchantSettlementServiceImpl implements MerchantSettlementService
} }
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,businessEntities,locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS,businessEntities,locale);
} }
/**
* 对商家入驻进行审核1审核通过 2审核不通过
* @param id
* @param
* @return
*/
@Transactional(rollbackOn = Exception.class)
@Override
public String updatePassBusiness(Integer id,String username,String province,String city,String county) {
Locale locale = LocaleContextHolder.getLocale();
BusinessEntity businessEntity = businessDao.findById(id);
if("1".equals(businessEntity.getBusinessType())){
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"该商家已被审核并已通过审核!",locale);
}
String salt = KeyGenerators.string().generateKey();
SysUserEntity sysUserEntity = new SysUserEntity();
sysUserEntity.setUserName(username);
sysUserEntity.setSalt(salt);
sysUserEntity.setPassword(encry256("lyb123" + salt));
sysUserEntity.setActiveFlag(0);
sysUserEntity.setStatusCode(0);
sysUserEntity.setAddTime(getNowTime());
sysUserEntity.setProvince(province);
sysUserEntity.setCity(city);
sysUserEntity.setCounty(county);
sysUserEntity.setDeleteFlag(0);
int i = (int)(Math.random()*9+1)*100000;
sysUserEntity.setIdentifier(String.valueOf(i));
sysUserEntity.setIdentity("affiliate_merchant");
sysUserDao.save(sysUserEntity);
RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity();
relUserRoleEntity.setUserId(sysUserEntity.getId().longValue());
relUserRoleEntity.setRoleId(6);
RelRoleAuthorityEntity relRoleAuthorityEntity = new RelRoleAuthorityEntity();
relRoleAuthorityEntity.setRoleId(6);
relRoleAuthorityEntity.setAuthorityId(6);
relUserRoleDao.save(relUserRoleEntity);
relRoleAuthorityDao.save(relRoleAuthorityEntity);
// 这一块整合手机号发送初始账号密码发送给对应得商家并提醒及时修改初始账号密码
// 修改商家入驻得状态通过
businessDao.updatePassBusiness(id);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"操作成功!",locale);
}
} }