diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/api/CustCasualApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/api/CustCasualApi.java new file mode 100644 index 00000000..f883e0fe --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/api/CustCasualApi.java @@ -0,0 +1,18 @@ +package net.xnzn.core.customer.api; + +import net.xnzn.core.customer.service.CustCasualRelationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class CustCasualApi { + + @Autowired + private CustCasualRelationService custCasualRelationService; + + + public void updateLoginState(Long userId, String openid) { + this.custCasualRelationService.updateBycustIdAndOpenid(userId, openid); + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/CustCasualRelationService.java b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/CustCasualRelationService.java new file mode 100644 index 00000000..b8344991 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/CustCasualRelationService.java @@ -0,0 +1,25 @@ +package net.xnzn.core.customer.service; + +import net.xnzn.constant.LeConstants; +import net.xnzn.core.customer.mapper.CustCasualRelationMapper; +import net.xnzn.core.customer.model.CustCasualRelation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class CustCasualRelationService { + + @Resource + private CustCasualRelationMapper custCasualRelationMapper; + + public void updateBycustIdAndOpenid(Long custId, String openId) { + CustCasualRelation custCasualRelation = new CustCasualRelation(); + custCasualRelation.setCustId(custId); + custCasualRelation.setOpenid(openId); + custCasualRelation.setIsDefault(LeConstants.COMMON_NO); + custCasualRelationMapper.updateByCustIdAndOpenId(custCasualRelation); + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/impl/CustInfoServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/impl/CustInfoServiceImpl.java index be3a13af..9b056485 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/impl/CustInfoServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/net/xnzn/core/customer/service/impl/CustInfoServiceImpl.java @@ -1,16 +1,25 @@ //package net.xnzn.core.customer.service.impl; // //import cn.hutool.core.util.ObjectUtil; +//import com.baomidou.mybatisplus.core.conditions.Wrapper; +//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +//import com.bonus.common.core.exception.ServiceException; +//import net.xnzn.constant.RetCodeEnum; +//import net.xnzn.core.customer.api.CustCasualApi; +//import net.xnzn.core.customer.constants.PersonalStatusEnum; //import net.xnzn.core.customer.dto.CustChangePasswordDTO; //import net.xnzn.core.customer.dto.CustForgetPasswordDTO; +//import net.xnzn.core.customer.mapper.CustInfoMapper; //import net.xnzn.core.customer.service.*; +//import net.xnzn.core.merchant.dto.SmsCodeVerifyDTO; //import net.xnzn.domain.CustInfo; +//import net.xnzn.utils.AesEncryptUtil; +//import net.xnzn.utils.SM4EncryptUtils; //import org.slf4j.Logger; //import org.slf4j.LoggerFactory; //import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Value; //import org.springframework.context.annotation.Lazy; -//import org.springframework.core.task.AsyncTaskExecutor; //import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //import org.springframework.stereotype.Service; //import java.util.*; @@ -27,30 +36,34 @@ // @Autowired // @Lazy // private CustCasualApi custCasualApi; +// @Autowired +// private CustInfoMapper custInfoMapper; // -// @Value("${customer.h5-login-default-pwd}") -// private String h5LoginPwd; +//// @Value("${customer.h5-login-default-pwd}") +//// private String h5LoginPwd; // // public void custChangePassword(CustChangePasswordDTO content) { -// CustInfo custInfo = (CustInfo)this.getOne((Wrapper)((LambdaQueryWrapper)(new LambdaQueryWrapper()).eq(CustInfo::getCustId, content.getCustId())).eq(CustInfo::getCustState, PersonalStatusEnum.NORMAL.getKey())); +// CustInfo custInfoQuery = new CustInfo(); +// custInfoQuery.setCustId(content.getCustId()); +// CustInfo custInfo = custInfoMapper.selectOne(custInfoQuery); // if (ObjectUtil.isNull(custInfo)) { // log.error("小程序修改密码错误:人员不存在:" + String.valueOf(custInfo)); -// throw new LeException(RetCodeEnum.PAY_PERSONAL_NO_EXIT, I18n.getMessage("customer.customer.inExists", new Object[0])); +// throw new ServiceException("小程序修改密码错误:人员不存在"); // } else { // String oldPassword = content.getOldPassword(); // String newPassword = content.getNewPassword(); // if (Objects.equals(oldPassword, newPassword)) { // log.error("小程序修改密码错误:两次密码不能一致"); -// throw new LeException(I18n.getMessage("customer.password.change.same", new Object[0])); +// throw new ServiceException("小程序修改密码错误:两次密码不能一致"); // } else { // BCryptPasswordEncoder bCrypt = new BCryptPasswordEncoder(); // if (!bCrypt.matches(oldPassword, custInfo.getPwd())) { // log.error("小程序修改密码错误:原密码不正确"); -// throw new LeException(I18n.getMessage("customer.password.ord.error", new Object[0])); +// throw new ServiceException("小程序修改密码错误:原密码不正确"); // } else { // String password = bCrypt.encode(newPassword); // custInfo.setPwd(password); -// this.updateById(custInfo); +// custInfoMapper.updateById(custInfo); // this.custCasualApi.updateLoginState(content.getCustId(), content.getOpenid()); // } // } @@ -64,18 +77,20 @@ // smsCodeVerifyDTO.setTelephoneNumber(content.getMobile()); // smsCodeVerifyDTO.setCode(content.getCode()); // if (!this.smsCodeApi.verifySmsCode(smsCodeVerifyDTO)) { -// throw new LeException(I18n.getMessage("notice_verify_sms_code_exception", new Object[0])); +// throw new ServiceException("验证码异常"); // } else { -// CustInfo custInfo = (CustInfo)this.getOne((Wrapper)((LambdaQueryWrapper)(new LambdaQueryWrapper()).eq(CustInfo::getMobile, SM4EncryptUtils.sm4Encryptbyconfig(content.getMobile()))).eq(CustInfo::getCustState, PersonalStatusEnum.NORMAL.getKey())); +// CustInfo custInfoQuery = new CustInfo(); +// custInfoQuery.setMobile(SM4EncryptUtils.sm4Encryptbyconfig(content.getMobile())); +// CustInfo custInfo = custInfoMapper.selectOne(custInfoQuery); // if (ObjectUtil.isNull(custInfo)) { // log.error("修改密码错误:人员不存在:" + String.valueOf(custInfo)); -// throw new LeException(RetCodeEnum.PAY_PERSONAL_NO_EXIT, I18n.getMessage("customer.customer.inExists", new Object[0])); +// throw new ServiceException("修改密码错误:人员不存在", RetCodeEnum.PAY_PERSONAL_NO_EXIT.getKey()); // } else { // String newPassword = content.getNewPassword(); // BCryptPasswordEncoder bCrypt = new BCryptPasswordEncoder(); // String password = bCrypt.encode(newPassword); // custInfo.setPwd(password); -// this.updateById(custInfo); +// custInfoMapper.updateById(custInfo); // } // } // }