Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
4be7bbe570
@ -0,0 +1,41 @@
|
||||
package com.fastbee.data.controller.userRecharge;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.fastbee.rechargecard.domain.dto.RechargecardUser;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.fastbee.common.core.controller.BaseController;
|
||||
import com.fastbee.common.core.domain.AjaxResult;
|
||||
import com.fastbee.rechargecard.domain.UserRechargeCards;
|
||||
import com.fastbee.rechargecard.service.IUserRechargeCardsService;
|
||||
import com.fastbee.common.utils.poi.ExcelUtil;
|
||||
import com.fastbee.common.core.page.TableDataInfo;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/rechargecard/user")
|
||||
@Api(tags = "用户充值卡")
|
||||
public class UserRechargeController extends BaseController {
|
||||
@Autowired
|
||||
private IUserRechargeCardsService userRechargeCardsService;
|
||||
|
||||
/**
|
||||
* 修改用户充值卡金额
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('rechargecard:cards:edit')")
|
||||
@PutMapping
|
||||
@ApiOperation("修改用户充值卡")
|
||||
public AjaxResult result(@RequestBody RechargecardUser rechargecardUser)
|
||||
{
|
||||
|
||||
return toAjax(userRechargeCardsService.updateUserRecharge(rechargecardUser));
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
@ -21,6 +22,7 @@ import com.fastbee.common.core.domain.BaseEntity;
|
||||
@ApiModel(value = "UserConsumptionDetails",description = "用户充值卡账单明细记录 user_consumption_details")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Builder
|
||||
public class UserConsumptionDetails extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.fastbee.rechargecard.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class RechargecardUser {
|
||||
private String cardnumber;
|
||||
private BigDecimal number;
|
||||
private Integer status;
|
||||
private String Areacode;
|
||||
}
|
@ -29,6 +29,12 @@ public interface UserRechargeCardsMapper extends MPJBaseMapper<UserRechargeCards
|
||||
*/
|
||||
public UserRechargeCards selectUserRechargeCardsById(Long id);
|
||||
|
||||
/**
|
||||
* card_number查询用户充值卡
|
||||
|
||||
* @return 用户充值卡
|
||||
*/
|
||||
public UserRechargeCards selectUserRechargeCardsByCardnumber(String cardnumber);
|
||||
/**
|
||||
* 查询用户充值卡列表
|
||||
*
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.fastbee.rechargecard.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import com.fastbee.rechargecard.domain.UserRechargeCards;
|
||||
import com.fastbee.rechargecard.domain.dto.RechargecardUser;
|
||||
|
||||
/**
|
||||
* 用户充值卡Service接口
|
||||
@ -61,4 +63,11 @@ public interface IUserRechargeCardsService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserRechargeCardsById(Long id);
|
||||
/**
|
||||
* 用户充值卡信息
|
||||
*
|
||||
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUserRecharge(RechargecardUser rechargecardUser);
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
package com.fastbee.rechargecard.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import com.fastbee.common.utils.DateUtils;
|
||||
import com.fastbee.rechargecard.domain.UserConsumptionDetails;
|
||||
import com.fastbee.rechargecard.domain.dto.RechargecardUser;
|
||||
import com.fastbee.rechargecard.mapper.UserConsumptionDetailsMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fastbee.rechargecard.mapper.UserRechargeCardsMapper;
|
||||
@ -23,7 +27,8 @@ public class UserRechargeCardsServiceImpl implements IUserRechargeCardsService
|
||||
private UserRechargeCardsMapper userRechargeCardsMapper;*/
|
||||
@Autowired
|
||||
private UserRechargeCardsMapper userRechargeCardsMapper;
|
||||
|
||||
@Autowired
|
||||
private UserConsumptionDetailsMapper userConsumptionDetailsMapper;
|
||||
@Override
|
||||
public Long test(Long id) {
|
||||
return userRechargeCardsMapper.test(id);
|
||||
@ -106,4 +111,33 @@ public class UserRechargeCardsServiceImpl implements IUserRechargeCardsService
|
||||
{
|
||||
return userRechargeCardsMapper.deleteUserRechargeCardsById(id);
|
||||
}
|
||||
/**
|
||||
* 用户充值卡信息
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserRecharge(RechargecardUser rechargecardUser){
|
||||
|
||||
// 根据id查询用户充值卡信息
|
||||
UserRechargeCards info = userRechargeCardsMapper.selectUserRechargeCardsByCardnumber(rechargecardUser.getCardnumber());
|
||||
if (info == null) {
|
||||
// 如果没有找到对应的记录,返回0或者一个错误码
|
||||
return 0;
|
||||
}
|
||||
// 计算新的余额
|
||||
BigDecimal newBalance = rechargecardUser.getNumber().add(info.getBalance());
|
||||
UserConsumptionDetails userConsumptionDetails= UserConsumptionDetails.builder()
|
||||
.userId(info.getUserId()).deviceNumber(null).cardNumber(info.getCardNumber())
|
||||
.projectId(null).deptId(null).billingType(0).pumpTime(null).unitPrice(null).totalPrice(null)
|
||||
.discount(null).taxAmount(null).amountDue(rechargecardUser.getNumber()).billingPeriodUnit(null).billingPeriodDuration(null)
|
||||
.billingDate(DateUtils.getNowDate()).startTime(null).endTime(null).paymentStatus(2).paymentMethod(rechargecardUser.getStatus())
|
||||
.paymentTime(DateUtils.getNowDate()).status(0).remark(null);
|
||||
|
||||
userConsumptionDetailsMapper.insertUserConsumptionDetails(userConsumptionDetails);
|
||||
// 更新用户充值卡信息,包括新的余额
|
||||
info.setBalance(newBalance);
|
||||
info.setUpdateTime(DateUtils.getNowDate());
|
||||
return userRechargeCardsMapper.updateUserRechargeCards(info);
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,11 @@
|
||||
<include refid="selectUserRechargeCardsVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectUserRechargeCardsByCardnumber" parameterType="String"
|
||||
resultMap="UserRechargeCardsResult">
|
||||
<include refid="selectUserRechargeCardsVo"/>
|
||||
where card_number= #{cardnumber}
|
||||
</select>
|
||||
|
||||
<insert id="insertUserRechargeCards" parameterType="UserRechargeCards" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into user_recharge_cards
|
||||
|
Loading…
x
Reference in New Issue
Block a user