golang正则关于=的替代
<?php
/**
* Created by PhpStorm.
* User: admin
* Date: 2018/8/21
* Time: 15:06
*/
namespace app\admino\controller;
use app\common\model\AdminModel;
use app\common\model\BannerModel;
use app\common\model\ClientModel;
use app\common\model\LogerModel;
use app\common\model\SignModel;
use app\common\model\SmsModel;
use app\common\model\SystemModel;
use app\common\model\TagModel;
use app\common\model\UserModel;
use app\common\model\WechatOfficialAccountModel;
use think\db\Query;
use think\Exception;
use think\Log;
use think\Session;
class UserExt extends SingleTableBase
{
protected $model = "user";
protected $primary_show = false;
protected $title = "门店会员管理";
protected $is_edit = false;
protected $is_add = false;
protected $is_del = false;
protected $is_show = false;
protected $is_export=true;
protected $index_view = "/UserExt/index";
protected $table_header = [
"created_at" => "注册日期",
"user_id" => "客户编号",
"username" => "客户姓名",
"gender" => "性别",
"phone" => "联系电话",
"openid"=>"openid",
"content" => "影像文件下载链接",
"share_time" => "分享链接日期",
];
protected $filter_header = ["created_at", "share_time"];
protected $table_option = [
"gender" => [
'type' => self::TYPE_SELECT,
'data' => [1 => "先生", 2 => "女士"],
],
"created_at" => [
'type' => self::TYPE_TIME,
],
"share_time" => [
'type' => self::TYPE_TIME,
],
];
protected $table_ext_button = [];
protected $search_header = ["phone", "username"];
protected function data(Query $model, $page, $search, $filter = false, $w = [])
{
if (empty($_REQUEST["filter"]) && empty($_REQUEST["search"])) {
$model->where(["id" => "999999999"]);
}
$admin_info = AdminModel::getInstance()->where(["id" => Session::get("user")["user_id"]])->find();
$w["business_id"] = $admin_info["business_id"];
$data = parent::data($model, $page, $search, $filter, $w); // TODO: Change the autogenerated stub
for ($i = 0; $i < count($data["data"]); $i++) {
$data["data"][$i]["user_id"] = $data["data"][$i]["business_id"] . "-" . $data["data"][$i]["user_number"];
}
return $data;
}
protected function saveDataFilter(&$data)
{
$data["type"] = $_REQUEST["type"];
parent::saveDataFilter($data); // TODO: Change the autogenerated stub
}
public function updateContent($id, $content)
{
$user_info = UserModel::getInstance()->where(["id" => $id])->find();
$admin_info = AdminModel::getInstance()->where(["business_id" => $user_info["business_id"]])->find();
$array = [1 => "先生", 2 => "女士"];
if ($admin_info["type"] == 0) {
$sms_name = SignModel::getInstance()->where(["id" => $admin_info["sms_id"]])->find()["ems_sign"];
$msg = "【{$sms_name}】尊敬的:{$user_info["username"]}{$array[$user_info["gender"]]}!您的影像文件可以下载了,请您务必于7天内扫描二维码或通过公众号登录下载,并妥善保存,谢谢!";
try {
SystemModel::sendCode($user_info["phone"], $msg);
SmsModel::getInstance()->add(["title" => "影像下载通知", "business_id" => Session::get("user")["business_id"], "user_name" => $admin_info["name"], "phone" => $user_info["phone"], "content" => $msg, "username" => $admin_info["username"], "name" => $user_info["username"], "business_sms_name" => $admin_info["business_sms_name"]]);
UserModel::getInstance()->where(["id" => $id])->save(["content" => $content, "share_time" => date("Y-m-d H:i:s")]);
} catch (Exception $exception) {
$this->displayByError($exception->getMessage());
}
$this->displayBySuccess();
}
if ($user_info["is_bind"] == 1) {
$this->displayByError("用户已解绑,无法推送");
}
if(empty($user_info["openid"])){
$this->displayByError("用户openid为空");
}
UserModel::getInstance()->where(["id" => $id])->save(["content" => $content, "share_time" => date("Y-m-d H:i:s")]);
$push_log = WechatOfficialAccountModel::sendMessage($user_info["openid"], $user_info["business_id"], "template_one",
"https://{$_SERVER['HTTP_HOST']}/Api/Login/download.html?id={$user_info["business_id"]}", "尊敬的{$user_info["username"]}{$array[$user_info["gender"]]},您的影像文件已经可以下载了,请您务必于7天内,点击本条信息“查看详情”登录下载,并妥善保存。", [$user_info["phone"], date("Y-m-d H:i:s")], "下载影像时,请先将整个文件夹保存到您的网盘,再登录您的网盘将文件下载到您的手机或电脑。可能有些文件在您的网盘里不能直接预览缩略图,这属于正常现象,请您先将文件下载到您的手机或电脑里,再从手机或电脑里打开文件就可以了,感谢您的配合");
LogerModel::addLog("push_log", json_encode($push_log));
$this->displayBySuccess();
}
public function search()
{
$this->displayByData([], "UserExt/search");
}
}