作者 Cool
1 个管道 的构建 通过 耗费 2 秒

商圈审核及过期定时任务调试

... ... @@ -116,6 +116,23 @@ class StoreInform extends Backend
Db::startTrans();
try {
$result = $row->save();
if($params['status'] == 4) {
$user_model = new \app\admin\model\User();
$user = $user_model->where('id', $row->user_id)->find();
// 积分变动记录
$log = [
'user_id' => $row->user_id,
'score' => $row->score,
'before' => $user['score'],
'after' => $user['score'] + $row->score,
'createtime' => time(),
'status' => 3,
'memo' => '商圈信息审核失败'
];
$result_log = Db::name('user_score_log')->insertGetId($log);
// 返还用户余额
$result_user = $user_model->where('id', $user['id'])->setInc('score', $row->score);
}
Db::commit();
} catch (ValidateException $e) {
Db::rollback();
... ...
... ... @@ -131,7 +131,7 @@ class UserWithdraw extends Backend
$result_pay = $merchantPay->send($merchantPayData);
if ($result_pay['return_code'] == 'SUCCESS' && $result_pay['result_code'] == 'SUCCESS') {
if($row->type == 1) {
// 余额变动记录
// 积分变动记录
$log = [
'user_id' => $row->user_id,
'score' => $row->money * $withdraw_percent,
... ... @@ -163,7 +163,7 @@ class UserWithdraw extends Backend
}
} else {
if($row->type == 1) {
// 余额变动记录
// 积分变动记录
$log = [
'user_id' => $row->user_id,
'score' => $row->money * $withdraw_percent,
... ...
... ... @@ -5,6 +5,7 @@ namespace app\index\controller;
use addons\litestore\model\Litestoreorder;
use addons\third\model\Third;
use addons\wechat\library\Config as ConfigService;
use app\api\model\StoreInform;
use app\common\controller\Frontend;
use EasyWeChat\Foundation\Application as WXPAY_APP;
use EasyWeChat\Foundation\Application;
... ... @@ -19,7 +20,7 @@ use think\Log;
class Ajax extends Frontend
{
protected $noNeedLogin = ['lang','callback_for_wxgzh','store_notify','store_order_notify','notify','refund_notify'];
protected $noNeedLogin = ['lang','store_inform_over','callback_for_wxgzh','store_notify','store_order_notify','notify','refund_notify'];
protected $noNeedRight = ['*'];
protected $layout = '';
public function _initialize()
... ... @@ -50,6 +51,47 @@ class Ajax extends Frontend
}
/**
* 商圈信息红包过期
*/
public function store_inform_over()
{
$inform_model = new StoreInform();
$time = strtotime(date('Y-m-d',time())) - 14 * 86400;
$end_time = $time + 86400 - 14 * 86400;
$where = [
'type' => 1,
'status' => 2,
'surplus' => ['gt',0],
'updatetime' => ['between',[$time,$end_time]]
];
$inform = $inform_model->where($where)->select();
foreach ($inform as &$v) {
Db::startTrans();
$res = $inform_model->update(['id'=>$v['id'],'status'=>5]);
$user_model = new \app\admin\model\User();
$user = $user_model->where('id', $v['user_id'])->find();
// 积分变动记录
$log = [
'user_id' => $v['user_id'],
'score' => $v['score'],
'before' => $user['score'],
'after' => $user['score'] + $v['score'],
'createtime' => time(),
'status' => 3,
'memo' => '商圈信息过期'
];
$result_log = Db::name('user_score_log')->insertGetId($log);
// 返还用户余额
$result_user = $user_model->where('id', $user['id'])->setInc('score', $v['score']);
if(!$res || !$result_log || !$result_user) {
Db::rollback();
}
Db::commit();
}
echo 'success';
}
/**
* 店铺申请回调
*/
public function store_notify()
... ...