作者 lihan
1 个管道 的构建 通过 耗费 0 秒

赠送积分模块

<?php
/**
* Created by PhpStorm.
* User: yhbr
* Date: 2018/10/23
* Time: 15:15
*/
namespace app\integral\controller;
use app\integral\model\IntegralModel;
use think\Db;
use cmf\controller\HomeBaseController;
class IntegralController extends HomeBaseController
{
public function autoExecute() {
$model = new IntegralModel;
$give = Db::name('zj_integral')->where(['balance'=>['neq', 0]])->field('id,uid,balance,ratio')->select();
foreach ($give as $item) {
$give_balance = (int)($item['balance'] * $item['ratio'] / 100);
$remain_balance = $item['balance'] - $give_balance;
$model->insertIntegralLog($item['id'], $item['uid'], time(), $give_balance, 1);
$model->updateIntegralGive($item['id'], $remain_balance);
}
}
}
\ No newline at end of file
... ...