From 411ac03e857fcd90f5b5ad3596fbf1682a579897 Mon Sep 17 00:00:00 2001 From: XinYi Song <2037158277@qq.com> Date: Mon, 20 Dec 2021 14:35:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=80=BB=E9=83=A8?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E5=95=86=E5=AE=B6=E5=85=A5=E9=A9=BB=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=EF=BC=88=E9=80=9A=E8=BF=87=EF=BC=89=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MerchantSettlementController.java | 15 ++++ src/main/java/com/xkrs/dao/BusinessDao.java | 28 ++++++++ .../service/MerchantSettlementService.java | 8 +++ .../impl/MerchantSettlementServiceImpl.java | 71 +++++++++++++++++-- 4 files changed, 118 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/xkrs/controller/MerchantSettlementController.java b/src/main/java/com/xkrs/controller/MerchantSettlementController.java index fa0f2e4..85bb199 100644 --- a/src/main/java/com/xkrs/controller/MerchantSettlementController.java +++ b/src/main/java/com/xkrs/controller/MerchantSettlementController.java @@ -117,4 +117,19 @@ public class MerchantSettlementController { String businessName = (String) map.get("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); + } } diff --git a/src/main/java/com/xkrs/dao/BusinessDao.java b/src/main/java/com/xkrs/dao/BusinessDao.java index a795c16..1c34766 100644 --- a/src/main/java/com/xkrs/dao/BusinessDao.java +++ b/src/main/java/com/xkrs/dao/BusinessDao.java @@ -3,6 +3,8 @@ package com.xkrs.dao; import com.xkrs.model.entity.BusinessEntity; import org.springframework.data.jpa.repository.JpaRepository; 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; @@ -64,4 +66,30 @@ public interface BusinessDao extends JpaRepository, JpaSpec * @return */ 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); + + } diff --git a/src/main/java/com/xkrs/service/MerchantSettlementService.java b/src/main/java/com/xkrs/service/MerchantSettlementService.java index ec6d178..d5b94a4 100644 --- a/src/main/java/com/xkrs/service/MerchantSettlementService.java +++ b/src/main/java/com/xkrs/service/MerchantSettlementService.java @@ -56,4 +56,12 @@ public interface MerchantSettlementService { * @return */ 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); } diff --git a/src/main/java/com/xkrs/service/impl/MerchantSettlementServiceImpl.java b/src/main/java/com/xkrs/service/impl/MerchantSettlementServiceImpl.java index 6171e24..3b2f0d6 100644 --- a/src/main/java/com/xkrs/service/impl/MerchantSettlementServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/MerchantSettlementServiceImpl.java @@ -1,10 +1,8 @@ package com.xkrs.service.impl; import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.dao.BankCardDao; -import com.xkrs.dao.BusinessDao; -import com.xkrs.model.entity.BankCardEntity; -import com.xkrs.model.entity.BusinessEntity; +import com.xkrs.dao.*; +import com.xkrs.model.entity.*; import com.xkrs.model.qo.BankCardQo; import com.xkrs.model.qo.BusinessQo; import com.xkrs.service.MerchantSettlementService; @@ -13,10 +11,12 @@ import com.xkrs.utils.PhotoUtil; import com.xkrs.utils.Query; import com.xkrs.utils.VerifyBankCardUtil; import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.security.crypto.keygen.KeyGenerators; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import javax.transaction.Transactional; import java.io.IOException; import java.time.LocalDateTime; import java.util.List; @@ -24,6 +24,8 @@ import java.util.Locale; import java.util.Map; 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 @@ -42,6 +44,15 @@ public class MerchantSettlementServiceImpl implements MerchantSettlementService @Resource private Query query; + @Resource + private SysUserDao sysUserDao; + + @Resource + private RelUserRoleDao relUserRoleDao; + + @Resource + private RelRoleAuthorityDao relRoleAuthorityDao; + /** * 商家入驻 * @param businessQo @@ -149,4 +160,56 @@ public class MerchantSettlementServiceImpl implements MerchantSettlementService } 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); + } }