| | |
| | | |
| | | import com.lunhan.water.common.*; |
| | | import com.lunhan.water.common.enums.*; |
| | | import com.lunhan.water.common.jwt.LoginUserDTO; |
| | | import com.lunhan.water.common.model.Tuple; |
| | | import com.lunhan.water.common.util.*; |
| | | import com.lunhan.water.entity.enums.EPayState; |
| | | import com.lunhan.water.entity.enums.EPayType; |
| | | import com.lunhan.water.entity.request.rechargerecords.Recharge; |
| | | import com.lunhan.water.repository.impl.RechargeOrderMapperImpl; |
| | | import com.lunhan.water.repository.impl.UserLoginMapperImpl; |
| | | import com.lunhan.water.repository.po.RechargeOrderPO; |
| | | import com.lunhan.water.repository.po.UserLoginPO; |
| | | import com.lunhan.water.repository.vo.PaymentRecordsVO; |
| | | import org.apache.commons.lang3.BooleanUtils; |
| | | 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.RechargeRecordsMapperImpl; |
| | |
| | | import com.lunhan.water.entity.search.SearchRechargeRecords; |
| | | import com.lunhan.water.repository.vo.RechargeRecordsVO; |
| | | import com.lunhan.water.service.convert.RechargeRecordsConvert; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | /** |
| | | * 充值记录 |
| | |
| | | public class RechargeRecordsService extends BaseService { |
| | | @Autowired |
| | | private RechargeRecordsMapperImpl mapper; |
| | | @Autowired |
| | | private UserLoginMapperImpl userLoginMapper; |
| | | @Autowired |
| | | private RechargeOrderMapperImpl rechargeOrderMapper; |
| | | |
| | | public ExecutedResult<Long> create(ReqCreateRechargeRecords request) { |
| | | // 转换po |
| | |
| | | } |
| | | return ExecutedResult.success(result); |
| | | } |
| | | |
| | | /** |
| | | * 充值订单 |
| | | * |
| | | * @param request |
| | | * @param loginUser |
| | | * @return |
| | | */ |
| | | public ExecutedResult<String> recharge(Recharge request, LoginUserDTO loginUser) { |
| | | Long now = LocalDateTimeUtil.nowTimeStamp(); |
| | | // 修改用户余额 |
| | | UserLoginPO userLoginPO = userLoginMapper.get4Openid(loginUser.getUserId()); |
| | | if (Objects.isNull(userLoginPO)) { |
| | | return ExecutedResult.failed("用户信息不存在!"); |
| | | } |
| | | RechargeOrderPO orderPO=new RechargeOrderPO(); |
| | | orderPO.setUserId(userLoginPO.getId()); |
| | | orderPO.setOrderNo("CZ"+SnowFlakeUtil.getId()); |
| | | orderPO.setOrderAmount(request.getRechargeAmount()); |
| | | orderPO.setDiscountAmount(BigDecimal.ZERO); |
| | | orderPO.setPaymentAmount(request.getRechargeAmount()); |
| | | orderPO.setPayType(EPayType.WX_PAY.getValue()); |
| | | orderPO.setPayState(EPayState.WAITING.getValue()); |
| | | orderPO.setCreateTime(now); |
| | | orderPO.setRemark("后台充值"); |
| | | int insert = rechargeOrderMapper.insert(orderPO); |
| | | if(insert>0){ |
| | | return ExecutedResult.success(orderPO.getOrderNo()); |
| | | } |
| | | return ExecutedResult.failed("提交充值订单失败!"); |
| | | } |
| | | public ExecutedResult<PagerResult<RechargeRecordsVO>> search(SearchRechargeRecords search) { |
| | | // 处理创建时间范围-查询参数 |
| | | if(search.getDateType()!=null&&search.getDateType()>0){ |