cxfoot/models/common/CommonCashWarnForm.php
2023-10-24 14:54:18 +08:00

63 lines
1.6 KiB
PHP

<?php
/**
* @author Any
* @description KISS
* @date 2021年6月11日
* @version 1.0.0
*
* _____LOG_____
*
*/
namespace app\models\common;
use app\models\UniqueOrderNo;
use app\models\User;
use app\models\Cash;
use app\models\Model;
use app\models\Balance;
use app\components\SysConst;
class CommonCashWarnForm extends Model
{
public $cash;
public function rules()
{
return [
[['cash'], 'required'],
['cash', function ($attribute, $param) {
if (!$this->cash instanceof Cash) {
$this->addError($attribute, 'cash必须是app\\models\Cash的对象');
}
}]
];
}
public function __construct(array $config = [])
{
parent::__construct($config);
}
public function afterTransfer()
{
if(!$this->validate()){
return $this->getModelError();
}
//账户余额变动
$scene_cn = Balance::getBalanceScene($this->cash->scene);
$desc = "{$scene_cn}提现";
$order_type = UniqueOrderNo::getOrderTypeByOrderNo($this->cash->order_no);
$ext = "";
$res = Balance::logger($this->cash->user_id, Balance::TYPE_PAY, $this->cash->money, $desc, $order_type, $this->cash->order_no, $this->cash->scene, $ext, $this->cash->cx_mch_id);
if($res['code'] != 0){
$err_msg = "---XDEBUG--> CASH_ID:{$this->cash->id} ERR_MSG:{$res['msg']}";
\Yii::error($err_msg);
}
return Model::asReturnSuccess();
}
}