82 lines
2.2 KiB
PHP
82 lines
2.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2021年11月25日
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\models\common;
|
|
|
|
use app\models\Balance;
|
|
use app\models\BalanceLog;
|
|
use app\models\User;
|
|
use app\models\Model;
|
|
use app\models\UniqueOrderNo;
|
|
use yii\data\Pagination;
|
|
use app\components\SiteHelper;
|
|
|
|
|
|
class CommonBalanceLogActionForm extends Model
|
|
{
|
|
public $cx_mch_id;
|
|
public $scene;
|
|
public $blog_id;
|
|
public $user_id;
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['blog_id',], 'safe'],
|
|
[['cx_mch_id', 'user_id', 'scene'], 'integer'],
|
|
[['blog_id', 'user_id'], 'required', 'on' => 'delete'],
|
|
[['cx_mch_id',], 'required'],
|
|
];
|
|
}
|
|
|
|
|
|
public function delete()
|
|
{
|
|
if(!$this->validate()){
|
|
return $this->getModelError();
|
|
}
|
|
if(is_array($this->blog_id)){
|
|
foreach ($this->blog_id as $blog_id){
|
|
$model = BalanceLog::findOne([
|
|
'id' => $blog_id,
|
|
'scene' => $this->scene,
|
|
'is_delete' => 0,
|
|
'user_id' => $this->user_id,
|
|
'cx_mch_id' => $this->cx_mch_id
|
|
]);
|
|
if($model == null)
|
|
continue;
|
|
$model->is_delete = 1;
|
|
if(!$model->save()){
|
|
return $this->getModelError($model);
|
|
}
|
|
}
|
|
} else {
|
|
$model = BalanceLog::findOne([
|
|
'id' => $this->blog_id,
|
|
'scene' => $this->scene,
|
|
'is_delete' => 0,
|
|
'user_id' => $this->user_id,
|
|
'cx_mch_id' => $this->cx_mch_id
|
|
]);
|
|
if($model == null){
|
|
return $this->apiReturnError('钱包明细不存在或已经删除');
|
|
}
|
|
$model->is_delete = 1;
|
|
if(!$model->save()){
|
|
return $this->getModelError($model);
|
|
}
|
|
}
|
|
return $this->apiReturnSuccess("删除成功");
|
|
}
|
|
}
|
|
|