| | |
| | | import com.lunhan.water.entity.enums.EUserType; |
| | | import com.lunhan.water.entity.request.ReqChangePassword; |
| | | import com.lunhan.water.entity.request.ReqUserLogin; |
| | | import com.lunhan.water.repository.impl.PaymentRecordsMapperImpl; |
| | | import com.lunhan.water.repository.impl.RechargeRecordsMapperImpl; |
| | | import org.apache.commons.lang3.BooleanUtils; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import com.lunhan.water.repository.impl.UserLoginMapperImpl; |
| | |
| | | public class UserLoginService extends BaseService { |
| | | @Autowired |
| | | private UserLoginMapperImpl mapper; |
| | | @Autowired |
| | | private RechargeRecordsMapperImpl rechargeRecordsMapper; |
| | | @Autowired |
| | | private PaymentRecordsMapperImpl paymentRecordsMapper; |
| | | |
| | | public ExecutedResult<Long> create(ReqCreateUserLogin request) { |
| | | // 转换po |
| | |
| | | if (checkExists.isFailed()) { |
| | | return ExecutedResult.failed(checkExists.getMsg()); |
| | | } |
| | | //UserLoginPO data = checkExists.getData(); |
| | | // 转换po |
| | | UserLoginPO item = UserLoginConvert.INSTANCE.toModify(request); |
| | | |
| | | UserLoginPO item =new UserLoginPO(); |
| | | item.setId( checkExists.getData().getId()); |
| | | item.setNickName(request.getNickName()); |
| | | item.setHeadImg(request.getHeadImg()); |
| | | int rowCount = mapper.updateById(item); |
| | | if (rowCount != 1) { |
| | | return ExecutedResult.failed("编辑[null]失败。"); |
| | | return ExecutedResult.failed("编辑用户信息失败。"); |
| | | } |
| | | return ExecutedResult.success(); |
| | | } |
| | |
| | | } |
| | | return ExecutedResult.success(result); |
| | | } |
| | | public ExecutedResult<UserLoginVO> getUser(LoginUserDTO loginUser){ |
| | | UserLoginPO userLoginPO = mapper.get4Openid(loginUser.getUserId()); |
| | | if(Objects.isNull(userLoginPO)){ |
| | | return ExecutedResult.failed("未获取到用户信息!"); |
| | | } |
| | | UserLoginVO userLoginVO = CopierUtil.mapTo(userLoginPO, UserLoginVO.class); |
| | | //查询总够水量 |
| | | BigDecimal sumBuyCount = rechargeRecordsMapper.getSumBuyCount(userLoginPO.getId()); |
| | | //查询总用水量 |
| | | BigDecimal sumUseCount = paymentRecordsMapper.getSumUseCount(userLoginPO.getId()); |
| | | userLoginVO.setSumBuyCount(sumBuyCount); |
| | | userLoginVO.setSumUseCount(sumUseCount); |
| | | |
| | | |
| | | return ExecutedResult.success(userLoginVO); |
| | | } |
| | | // public ExecutedResult<String> stop(Long id) { |
| | | // // 验证记录是否存在 |
| | | // ExecutedResult<UserLoginPO> checkExists = this.check4Id(id); |