作者 李洪娟

Merge branch 'master' of http://114.215.101.231:8099/lihan/integral into lilijuan

... ... @@ -127,14 +127,23 @@ class FriendController extends HomeBaseController
if ($total > 0) {
if (Db::name('user')->where(['id' => $uid])->setDec('balance', $total)) {
if (Db::name('user')->where(['id' => $friend_id])->setInc('balance', $total)) {
//插入赠送记录日志log
//记录日志log
$log = [
'uid' => $friend_id,
'create_time' => time(),
'balance' => $total,
'type' => 3
0 => [
'uid' => $friend_id,
'create_time' => time(),
'balance' => $total,
'type' => 3
],
1 => [
'uid' => session('user.id'),
'create_time' => time(),
'balance' => $total,
'type' => 4
]
];
if (Db::name('zj_integral_log')->insert($log)) {
if (Db::name('zj_integral_log')->insertAll($log)) {
Db::commit();
$tag = true;
} else {
... ...
... ... @@ -42,11 +42,6 @@ class IndexController extends HomeBaseController
]);
}
//强制绑定手机页面
public function login() {
return $this->fetch();
}
/**
* 易连云打印机demo
*/
... ...
... ... @@ -9,23 +9,29 @@
namespace app\integral\controller;
use app\integral\model\IntegralModel;
use think\Db;
use cmf\controller\PayBaseController;
use cmf\controller\NoneBaseController;
class IntegralController extends PayBaseController
class IntegralController extends NoneBaseController
{
public function autoExecute() {
$model = new IntegralModel;
$give = Db::name('zj_integral_give')->where(['balance'=>['neq', 0]])->field('id,uid,balance,total,ratio')->select();
foreach ($give as $item) {
$give_balance = (int)($item['total'] * $item['ratio'] / 100);
$remain_balance = $item['balance'] - $give_balance;
if($remain_balance < 0) {
$give_balance = $remain_balance;
$remain_balance = 0;
public function autoExecuteIntegral()
{
$start = date('23:57');
$end = date('23:59');
$now = date('H:i');
if ($now >= $start && $now <= $end) {
$model = new IntegralModel;
$give = Db::name('zj_integral_give')->where(['balance' => ['neq', 0]])->field('id,uid,balance,total,ratio')->select();
foreach ($give as $item) {
$give_balance = (int)($item['total'] * $item['ratio'] / 100);
$remain_balance = $item['balance'] - $give_balance;
if ($remain_balance < 0) {
$give_balance = $remain_balance;
$remain_balance = 0;
}
Db::name('user')->where(['id' => $item['uid']])->setInc('balance', $give_balance);
$model->insertIntegralLog($item['id'], $item['uid'], time(), $give_balance, 1);
$model->updateIntegralGive($item['id'], $remain_balance);
}
Db::name('user')->where(['id'=>$item['uid']])->setInc('balance', $give_balance);
$model->insertIntegralLog($item['id'], $item['uid'], time(), $give_balance, 1);
$model->updateIntegralGive($item['id'], $remain_balance);
}
}
}
\ No newline at end of file
... ...
<?php
/**
* Created by PhpStorm.
* User: yhbr
* Date: 2018/11/10
* Time: 9:50
*/
namespace app\login\controller;
use cmf\controller\NoneBaseController;
class LoginController extends NoneBaseController
{
//强制绑定手机页面
public function login() {
return $this->fetch();
}
}
\ No newline at end of file
... ...
... ... @@ -7,10 +7,10 @@
*/
namespace app\sms\controller;
use cmf\controller\HomeBaseController;
use cmf\controller\NoneBaseController;
use think\Db;
class SmsController extends HomeBaseController
class SmsController extends NoneBaseController
{
public function sendSms()
{
... ... @@ -34,20 +34,52 @@ class SmsController extends HomeBaseController
}
}
//单纯发送验证码
public function checkCode()
{
$mobile = request()->param('mobile');
$code = request()->param('code');
$data = Db::name('zj_code')->field('mobile,code,expire_time')->where(['mobile' => $mobile])->find();
if (time() > $data['expire_time']) {
$this->success('验证码已过期,请重新发送', '', false);
if (!empty($data)) {
if (time() > $data['expire_time']) {
$this->success('验证码已过期,请重新发送', '', false);
} else {
if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) {
Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']);
$this->success('身份信息核实成功', url(''), true);
} else {
$this->success('验证码有误', '', false);
}
}
} else {
if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) {
Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']);
$this->success('身份信息核实成功', url(''), true);
$this->success('验证码有误', '', false);
}
}
//修改密码、个人信息时的校验(必须验证输入手机号和原绑定手机号一致)
public function checkCodeS()
{
$mobile = request()->param('mobile');
$code = request()->param('code');
$data = Db::name('zj_code')->field('mobile,code,expire_time')->where(['mobile' => $mobile])->find();
$mobile = DB::name('user')->where(['id' => session('user.id')])->value('mobile');
if (!empty($data)) {
if ($mobile == $data['mobile']) {
if (time() > $data['expire_time']) {
$this->success('验证码已过期,请重新发送', '', false);
} else {
if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) {
Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']);
$this->success('身份信息核实成功', url(''), true);
} else {
$this->success('验证码有误', '', false);
}
}
} else {
$this->success('验证码有误', '', false);
$this->success('请输入原始绑定手机号码', '', false);
}
} else {
$this->success('验证码有误', '', false);
}
}
... ... @@ -56,16 +88,20 @@ class SmsController extends HomeBaseController
$mobile = request()->param('mobile');
$code = request()->param('code');
$data = Db::name('zj_code')->field('mobile,code,expire_time')->where(['mobile' => $mobile])->find();
if (time() > $data['expire_time']) {
$this->success('验证码已过期,请重新发送', '', false);
} else {
if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) {
Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']);
Db::name('user')->update(['id' => session('user.id'), 'mobile' => $mobile]);
$this->success('绑定成功', url(''), true);
if (!empty($data)) {
if (time() > $data['expire_time']) {
$this->success('验证码已过期,请重新发送', '', false);
} else {
$this->success('验证码有误', '', false);
if ($code == $data['code'] && $code != null && $data['code'] != null && $mobile == $data['mobile']) {
Db::name('zj_code')->where(['mobile' => $mobile])->update(['code' => '']);
Db::name('user')->update(['id' => session('user.id'), 'mobile' => $mobile]);
$this->success('绑定成功', url(''), true);
} else {
$this->success('验证码有误', '', false);
}
}
} else {
$this->success('验证码有误', '', false);
}
}
... ...
... ... @@ -56,9 +56,9 @@ class AdminIndexController extends AdminBaseController
*/
public function index()
{
$where = ['user_type'=>2];
$where1=[];
$where3=[];
$where = ['user_type' => 2];
$where1 = [];
$where3 = [];
$param = request()->param();
... ... @@ -67,28 +67,73 @@ class AdminIndexController extends AdminBaseController
$keyword = $param['keyword'];
$keywordComplex['mobile|id'] = $keyword;
}
if (!empty($param['start_time'])){
$where['create_time']=['egt',strtotime($param['start_time'])];
}
if (!empty($param['end_time'])){
$where1['create_time']=['elt',strtotime($param['end_time'])];
if (!empty($param['start_time'])) {
$where['create_time'] = ['egt', strtotime($param['start_time'])];
}
if (!empty($param['end_time'])) {
$where1['create_time'] = ['elt', strtotime($param['end_time'])];
}
if (!empty($param['min'])){
$where['balance']=['egt',$param['min']];
if (!empty($param['min'])) {
$where['balance'] = ['egt', $param['min']];
}
if (!empty($param['max'])){
$where1['balance']=['elt',$param['max']];
if (!empty($param['max'])) {
$where1['balance'] = ['elt', $param['max']];
}
$uid = (isset($param['uid'])) ? $param['uid'] : null;
//下级人员
if($uid) {
if ($uid) {
$where3['parent_id'] = ['eq', $uid];
}
$usersQuery = Db::name('user');
$list = $usersQuery->whereOr($keywordComplex)->where($where)->where($where1)->where($where3)->order("create_time DESC")->paginate(10);
//获取订单数和会员专区金额统计
foreach ($list as $k => $item) {
$uid = $item['id'];
$role = $item['role'];
//如果此人为普通会员,只统计其金额总和
if ($role == 1) {
$map = [
'uid' => ['eq', $item['id']],
'pay_type' => ['eq', 3],
'step' => ['neq', 1]
];
$data = Db::name('zj_order')->where($map)->field('sum(whole) as whole,sum(whole_num) as whole_num')->select();
$whole = $data[0]['whole'];
$whole_num = $data[0]['whole_num'];
$total = $whole - $whole_num;
} else {
//先查此人的下级
$son_arr = Db::name('user')->where(['parent_id' => $item['id']])->field('id')->select()->toArray();
if (!empty($son_arr)) {
$son_str = '';
foreach ($son_arr as $key => $v) {
if ($key == count($son_arr) - 1) {
$son_str .= $v['id'];
} else {
$son_str .= $v['id'] . ',';
}
}
$map = [
'uid' => ['in', $son_str],
'pay_type' => ['eq', 3],
'step' => ['neq', 1]
];
$data = Db::name('zj_order')->where($map)->field('sum(whole) as whole,sum(whole_num) as whole_num')->select();
$whole = $data[0]['whole'];
$whole_num = $data[0]['whole_num'];
$total = $whole - $whole_num;
} else {
$total = 0;
}
}
$item['total'] = $total;
$list[$k] = $item;
}
// 获取分页显示
$list->appends($param);
$this->assign('start_time', isset($param['start_time']) ? $param['start_time'] : '');
... ... @@ -158,12 +203,13 @@ class AdminIndexController extends AdminBaseController
/**
* 用户积分详情
*/
public function balance(){
if ($this->request->param()){
$id=input('param.id');
$all=Db::name('zj_integral_log')->where('uid',$id)->paginate(20);
$this->assign('list',$all);
$this->assign('page',$all->render());
public function balance()
{
if ($this->request->param()) {
$id = input('param.id');
$all = Db::name('zj_integral_log')->where('uid', $id)->paginate(20);
$this->assign('list', $all);
$this->assign('page', $all->render());
return $this->fetch();
}
}
... ...
... ... @@ -380,10 +380,13 @@ class CenterController extends HomeBaseController
$type = request()->param('type');
if ($type == 1) {
$title = '积分获取记录';
$where['type'] = ['in', "1,3"];
} else {
$title = '积分使用记录';
$where['type'] = ['in', "2,4"];
}
$log = Db::name('zj_integral_log')->where(['uid' => session('user.id'), 'type' => $type])->order('create_time DESC')->select();
$where['uid'] = ['eq', session('user.id')];
$log = Db::name('zj_integral_log')->where($where)->order('create_time DESC')->select();
return $this->fetch('integral_log', [
'log' => $log,
'title' => $title
... ...
... ... @@ -36,6 +36,7 @@
<th>下单量</th>
<th style="width:160px">{:lang('REGISTRATION_TIME')}</th>
<th>积分余额</th>
<th>会员专区金额统计</th>
<th>{:lang('STATUS')}</th>
<th style="width: 450px;">{:lang('ACTIONS')}</th>
</tr>
... ... @@ -52,6 +53,7 @@
<td>{$vo.order_count}</td>
<td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
<td>{$vo.balance}</td>
<td>{$vo.total}</td>
<td>{$user_statuses[$vo['user_status']]}</td>
<td>
<neq name="vo.id" value="1">
... ... @@ -65,7 +67,9 @@
</empty>
<a href="{:url('balance',array('id'=>$vo['id']))}">查看积分详情</a> |
<a href="{:url('admin/zj_order/index',array('uid'=>$vo.id))}">查看用户订单</a> |
<if condition="$vo.parent_id eq ''">
<a href="{:url('admin/User/role', ['uid'=>$vo['id']])}">变更角色</a>
</if>
<if condition="$vo['role'] eq '2'"> | <a href="{:url('user/adminIndex/index',['uid'=>$vo['id']])}">查看下级人员</a></if>
<else/>
<a style="color: #ccc;">{:lang('BLOCK_USER')}</a>
... ...
... ... @@ -151,7 +151,7 @@
alert('请输入验证码');
}else {
$.ajax({
url:"{:url('sms/Sms/checkCode')}",
url:"{:url('sms/Sms/checkCodeS')}",
data:{
mobile:mobile,
code:code
... ...
... ... @@ -151,7 +151,7 @@
alert('请输入验证码');
}else {
$.ajax({
url:"{:url('sms/Sms/checkCode')}",
url:"{:url('sms/Sms/checkCodeS')}",
data:{
mobile:mobile,
code:code
... ...
... ... @@ -41,13 +41,16 @@
<div class="good_intergral">
<p class="buy_good">
<if condition="$vo['type'] eq '1'">
购买商品获得
购买商品收入
</if>
<if condition="$vo['type'] eq '2'">
购买商品消费
购买商品支出
</if>
<if condition="$vo['type'] eq '3'">
好友购买奖励
好友赠送收入
</if>
<if condition="$vo['type'] eq '4'">
好友赠送支出
</if>
</p>
<p class="good_date">{$vo.create_time|date='Y-m-d', ###}</p>
... ...
... ... @@ -59,6 +59,10 @@ class HomeBaseController extends BaseController
}
}
}
}else {
if(Db::name('user')->where(['id'=>session('user.id')])->value('mobile') == null) {
$this->redirect(url('login/Login/login'));
}
}
}else {
$this->error('请从微信浏览器打开');
... ...
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +---------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace cmf\controller;
use app\user\model\UserModel;
use think\Db;
use app\admin\model\ThemeModel;
use think\View;
class NoneBaseController extends BaseController
{
public function _initialize()
{
parent::_initialize(); // TODO: Change the autogenerated stub
// 监听home_init
hook('home_init');
parent::_initialize();
$siteInfo = cmf_get_site_info();
View::share('site_info', $siteInfo);
}
public function _initializeView()
{
$cmfThemePath = config('cmf_theme_path');
$cmfDefaultTheme = cmf_get_current_theme();
$themePath = "{$cmfThemePath}{$cmfDefaultTheme}";
$root = cmf_get_root();
//使cdn设置生效
$cdnSettings = cmf_get_option('cdn_settings');
if (empty($cdnSettings['cdn_static_root'])) {
$viewReplaceStr = [
'__ROOT__' => $root,
'__TMPL__' => "{$root}/{$themePath}",
'__STATIC__' => "{$root}/static",
'__WEB_ROOT__' => $root
];
} else {
$cdnStaticRoot = rtrim($cdnSettings['cdn_static_root'], '/');
$viewReplaceStr = [
'__ROOT__' => $root,
'__TMPL__' => "{$cdnStaticRoot}/{$themePath}",
'__STATIC__' => "{$cdnStaticRoot}/static",
'__WEB_ROOT__' => $cdnStaticRoot
];
}
$viewReplaceStr = array_merge(config('view_replace_str'), $viewReplaceStr);
config('template.view_base', "{$themePath}/");
config('view_replace_str', $viewReplaceStr);
$themeErrorTmpl = "{$themePath}/error.html";
if (file_exists_case($themeErrorTmpl)) {
config('dispatch_error_tmpl', $themeErrorTmpl);
}
$themeSuccessTmpl = "{$themePath}/success.html";
if (file_exists_case($themeSuccessTmpl)) {
config('dispatch_success_tmpl', $themeSuccessTmpl);
}
}
/**
* 加载模板输出
* @access protected
* @param string $template 模板文件名
* @param array $vars 模板输出变量
* @param array $replace 模板替换
* @param array $config 模板参数
* @return mixed
*/
protected function fetch($template = '', $vars = [], $replace = [], $config = [])
{
$template = $this->parseTemplate($template);
$more = $this->getThemeFileMore($template);
$this->assign('theme_vars', $more['vars']);
$this->assign('theme_widgets', $more['widgets']);
return parent::fetch($template, $vars, $replace, $config);
}
/**
* 自动定位模板文件
* @access private
* @param string $template 模板文件规则
* @return string
*/
private function parseTemplate($template)
{
// 分析模板文件规则
$request = $this->request;
// 获取视图根目录
if (strpos($template, '@')) {
// 跨模块调用
list($module, $template) = explode('@', $template);
}
$viewBase = config('template.view_base');
if ($viewBase) {
// 基础视图目录
$module = isset($module) ? $module : $request->module();
$path = $viewBase . ($module ? $module . DS : '');
} else {
$path = isset($module) ? APP_PATH . $module . DS . 'view' . DS : config('template.view_path');
}
$depr = config('template.view_depr');
if (0 !== strpos($template, '/')) {
$template = str_replace(['/', ':'], $depr, $template);
$controller = cmf_parse_name($request->controller());
if ($controller) {
if ('' == $template) {
// 如果模板文件名为空 按照默认规则定位
$template = str_replace('.', DS, $controller) . $depr . $request->action();
} elseif (false === strpos($template, $depr)) {
$template = str_replace('.', DS, $controller) . $depr . $template;
}
}
} else {
$template = str_replace(['/', ':'], $depr, substr($template, 1));
}
return $path . ltrim($template, '/') . '.' . ltrim(config('template.view_suffix'), '.');
}
/**
* 获取模板文件变量
* @param string $file
* @param string $theme
* @return array
*/
private function getThemeFileMore($file, $theme = "")
{
//TODO 增加缓存
$theme = empty($theme) ? cmf_get_current_theme() : $theme;
// 调试模式下自动更新模板
if (APP_DEBUG) {
$themeModel = new ThemeModel();
$themeModel->updateTheme($theme);
}
$themePath = config('cmf_theme_path');
$file = str_replace('\\', '/', $file);
$file = str_replace('//', '/', $file);
$file = str_replace(['.html', '.php', $themePath . $theme . "/"], '', $file);
$files = Db::name('theme_file')->field('more')->where(['theme' => $theme])->where(function ($query) use ($file) {
$query->where(['is_public' => 1])->whereOr(['file' => $file]);
})->select();
$vars = [];
$widgets = [];
foreach ($files as $file) {
$oldMore = json_decode($file['more'], true);
if (!empty($oldMore['vars'])) {
foreach ($oldMore['vars'] as $varName => $var) {
$vars[$varName] = $var['value'];
}
}
if (!empty($oldMore['widgets'])) {
foreach ($oldMore['widgets'] as $widgetName => $widget) {
$widgetVars = [];
if (!empty($widget['vars'])) {
foreach ($widget['vars'] as $varName => $var) {
$widgetVars[$varName] = $var['value'];
}
}
$widget['vars'] = $widgetVars;
$widgets[$widgetName] = $widget;
}
}
}
return ['vars' => $vars, 'widgets' => $widgets];
}
public function checkUserLogin()
{
$userId = cmf_get_current_user_id();
if (empty($userId)) {
$this->error("用户尚未登录", url("user/login/index"));
}
}
}
\ No newline at end of file
... ...
... ... @@ -8,7 +8,7 @@ class Doc
'version'=>'1.0.0',
'copyright'=>'银河百荣科技',
'controller' => [
'api\\index\\controller\\IndexController'
'api\\home\\controller\\IndexController'
],
'password'=>'bronet',
'static_path'=>'',
... ...