Administrator
2024-01-31 3447c6321d90416d86bd6bd6515589bae3911c65
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wallet/WalletSv.java
@@ -1,10 +1,13 @@
package com.dy.pipIrrSell.wallet;
import com.dy.pipIrrGlobal.daoSe.SeConsumeMapper;
import com.dy.pipIrrGlobal.daoSe.SeRefundMapper;
import com.dy.pipIrrGlobal.daoSe.SeWalletMapper;
import com.dy.pipIrrGlobal.daoSe.SeWalletRechargeHistoryMapper;
import com.dy.pipIrrGlobal.daoSe.SeWalletRechargeMapper;
import com.dy.pipIrrGlobal.pojoSe.SeConsume;
import com.dy.pipIrrGlobal.pojoSe.SeRefund;
import com.dy.pipIrrGlobal.pojoSe.SeWallet;
import com.dy.pipIrrGlobal.pojoSe.SeWalletRechargeHistory;
import com.dy.pipIrrGlobal.pojoSe.SeWalletRecharge;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -26,54 +29,86 @@
    private SeWalletRechargeMapper seWalletRechargeMapper;
    @Autowired
    private SeWalletRechargeHistoryMapper seWalletRechargeHistoryMapper;
    private SeConsumeMapper seConsumeMapper;
    @Autowired
    private SeRefundMapper seRefundMapper;
    /**
     * 根据农户ID获取电子钱包对象
     * @param clientId
     * @return
     */
    public SeWallet getWalletByClientId(Long clientId) {
        return seWalletMapper.getWalletByClientId(clientId);
    }
    /**
     * 注册电子钱包账号
     * @param po 电子钱包实体类
     * @return 电子钱包ID
     */
    public Long addWallet(SeWallet po) {
        seWalletMapper.insert(po);
        return po.getId();
    }
    /**
     * 电子钱包充值
     * @param po
     * @return
     */
    public Integer add(SeWallet po) {
        return seWalletMapper.insert(po);
    public Long addRecharge(SeWalletRecharge po) {
        seWalletRechargeMapper.insert(po);
        return po.getId();
    }
    /**
     * 根据编号从钱包表中获取该钱包余额
     * @param id
     * 电子钱包消费
     * @param po
     * @return
     */
    public Float getMoneyById(Long id) {
        SeWallet po = seWalletMapper.selectByPrimaryKey(id);
        return po.getMoney();
    public Long addConsume(SeConsume po) {
        seConsumeMapper.insert(po);
        return po.getId();
    }
    /**
     * 根据钱包编号修改钱包余额
     * @param id 钱包编号(主键)
     * @param money 钱包余额
     * @return 修改记录数量
     */
    public Integer updateMoneyById(Long id, Float money) {
        SeWallet po = seWalletMapper.selectByPrimaryKey(id);
        po.setMoney(money);
        return seWalletMapper.updateByPrimaryKey(po);
    }
    /**
     * 根据id删除充值记录
     * @param id
     * 添加退款申请
     * @param po
     * @return
     */
    public Integer deleteWallerRechargeById(Long id) {
        return seWalletMapper.deleteByPrimaryKey(id);
    public Long addRefund(SeRefund po) {
        seRefundMapper.insert(po);
        return po.getId();
    }
    /**
     * 将充值记录添加到充值历史表
     * @param po 充值历史实体
     * 根据钱包ID获取待审核的退款申请对象
     * @param walletId
     * @return
     */
    public Integer addWallerRechargeHistory(SeWalletRechargeHistory po) {
        return seWalletRechargeHistoryMapper.insert(po);
    public SeRefund getRefundByWallerId(Long walletId) {
        return seRefundMapper.getRefundByWallerId(walletId);
    }
    /**
     * 审核退款申请
     * @param po
     * @return
     */
    public Integer auditRefund(SeRefund po) {
        return seRefundMapper.updateByPrimaryKeySelective(po);
    }
    /**
     * 修改电子钱包
     * 充值、消费、申请退款、审核退款时需要修改电子钱包的:余额、最后操作、最后操作时间
     * @param po
     * @return
     */
    public Integer updateWallet(SeWallet po) {
        return seWalletMapper.updateByPrimaryKeySelective(po);
    }
}