64 lines
1.3 KiB
PHP
64 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-23
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\modules\admin\models\wechat;
|
|
|
|
|
|
use app\models\Option;
|
|
use app\models\wechat\WechatAppTplMsg;
|
|
use app\modules\admin\models\AdminModel;
|
|
|
|
|
|
class WechatAppTplMsgForm extends AdminModel
|
|
{
|
|
public $template_ids;
|
|
|
|
public $cx_mch_id;
|
|
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['template_ids'], 'safe'],
|
|
[['cx_mch_id'], 'integer'],
|
|
[['cx_mch_id'], 'required'],
|
|
];
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
$list = WechatAppTplMsg::getList();
|
|
foreach ($list as $index => $item){
|
|
$key = $item["key"];
|
|
$key = WechatAppTplMsg::getTplKey($key);
|
|
$value = Option::getOption($key, $this->cx_mch_id);
|
|
$item["value"] = $value;
|
|
$list[$index] = $item;
|
|
}
|
|
return $list;
|
|
}
|
|
|
|
|
|
public function save()
|
|
{
|
|
if(!$this->validate())
|
|
return $this->getModelError();
|
|
foreach($this->template_ids as $key => $val){
|
|
$val = trim($val);
|
|
$key = WechatAppTplMsg::getTplKey($key);
|
|
Option::setOption($key, $val, $this->cx_mch_id);
|
|
}
|
|
return [
|
|
'code' => 0,
|
|
'msg' => '保存成功'
|
|
];
|
|
}
|
|
} |