feat: init project codebase

This commit is contained in:
sinde21
2026-09-14 16:32:07 +08:00
parent c4b2a15757
commit da20fde7fb
140 changed files with 27855 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* User_model class.
*
* @extends CI_Model
*/
class Customer_model extends MY_Model
{
CONST SESSION_KEY = 'user';
CONST SESSION_KEY_WX_OPEN_ID = 'wx_open_id';
protected $table = 'user';
protected $join = [];
protected $keyword_field = ['nickname'];
//微信用户处理
public function weixin_users($data)
{
try {
$data = array(
'openid' => $data['openid'],
'unionid' => $data['unionid'],
'nickname' => $data['nickname'],
'sex' => $data['sex'],
'language' => $data['language'],
'city' => $data['city'],
'province' => $data['province'],
'country' => $data['country'],
'headimgurl' => $data['headimgurl'],
'is_server' => isset($data['is_server'])?$data['is_server']:0,
'update_time' => time()
);
$row = $this->get($data['unionid'], 'unionid');
if ($row) {
// 更新操作
$data['update_time'] = time();
$this->db->where('id', $row['id']);
$this->db->update('user', $data);
return $row['id'];
} else {
//新增操作
$data['create_time'] = $data['update_time'] = time();
$this->db->insert('user', $data);
return $this->db->insert_id();
}
} catch (Exception $ex) {
return FALSE;
}
}
}