package org.tio.sitexxx.service.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tio.jfinal.kit.Kv;
import org.tio.jfinal.plugin.activerecord.Db;
import org.tio.jfinal.plugin.activerecord.SqlPara;
import org.tio.sitexxx.service.vo.Const;

/**
 * <pre>
 *    @author : vagrancy
 *    e-mail : 18050829067@163.com
 *    time   : 2025-11-25 10:51
 *    desc   :
 * </pre>
 */
public class WxWalletCoinService {
    private static Logger log = LoggerFactory.getLogger(WxWalletCoinService.class);

    public static final WxWalletCoinService me = new WxWalletCoinService();

    /**
     * 充值
     * @param uid
     * @return
     *
     */
    public boolean subCoin(Integer uid, Long cny) {
        Kv params = Kv.by("uid", uid).set("cny", cny);
        SqlPara sqlPara = Db.use(Const.Db.TIO_SITE_MAIN).getSqlPara("walletCoin.subCoin", params);
        int updateRow = Db.use(Const.Db.TIO_SITE_MAIN).update(sqlPara);
        if (updateRow <= 0) {
            log.error("扣除，用户财务表数据异常.更新条数:{}", updateRow);
        }
        return updateRow > 0;
    }


    public boolean addCoid(Integer uid, Long cny) {
        Kv params = Kv.by("uid", uid).set("cny", cny);
        SqlPara sqlPara = Db.use(Const.Db.TIO_SITE_MAIN).getSqlPara("walletCoin.addCoin", params);
        int updateRow = Db.use(Const.Db.TIO_SITE_MAIN).update(sqlPara);
        if (updateRow <= 0) {
            log.error("充值，用户财务表数据异常.更新条数:{}", updateRow);
        }
        return updateRow > 0;
    }
}
