This commit is contained in:
parent
ec7f540aed
commit
437e68e6fe
|
|
@ -79,16 +79,6 @@ class UserController extends Controller
|
|||
if (!$validate_result) {
|
||||
return error($validate->getError());
|
||||
}
|
||||
//处理头像上传
|
||||
$attachment_avatar = new \app\common\model\Attachment;
|
||||
$file_avatar = $attachment_avatar->upload('avatar');
|
||||
if ($file_avatar) {
|
||||
$param['avatar'] = $file_avatar->url;
|
||||
} else {
|
||||
return error($attachment_avatar->getError());
|
||||
}
|
||||
|
||||
|
||||
$result = $model::create($param);
|
||||
|
||||
$url = URL_BACK;
|
||||
|
|
@ -112,16 +102,6 @@ class UserController extends Controller
|
|||
if (!$validate_result) {
|
||||
return error($validate->getError());
|
||||
}
|
||||
//处理头像上传
|
||||
if (!empty($_FILES['avatar']['name'])) {
|
||||
$attachment_avatar = new \app\common\model\Attachment;
|
||||
$file_avatar = $attachment_avatar->upload('avatar');
|
||||
if ($file_avatar) {
|
||||
$param['avatar'] = $file_avatar->url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = $data->save($param);
|
||||
return $result ? success() : error();
|
||||
}
|
||||
|
|
@ -159,28 +139,28 @@ class UserController extends Controller
|
|||
public function enable($id, User $model)
|
||||
{
|
||||
$result = $model->whereIn('id', $id)->update(['status' => 1]);
|
||||
return $result ? success('操作成功', URL_RELOAD) : error();
|
||||
return success('操作成功', URL_RELOAD);
|
||||
}
|
||||
|
||||
//禁用
|
||||
public function disable($id, User $model)
|
||||
{
|
||||
$result = $model->whereIn('id', $id)->update(['status' => 0]);
|
||||
return $result ? success('操作成功', URL_RELOAD) : error();
|
||||
return success('操作成功', URL_RELOAD);
|
||||
}
|
||||
|
||||
//开启体验资格
|
||||
public function experience_enable($id, User $model)
|
||||
{
|
||||
$result = $model->whereIn('id', $id)->update(['is_experience' => 1]);
|
||||
return $result ? success('操作成功', URL_RELOAD) : error();
|
||||
return success('操作成功', URL_RELOAD);
|
||||
}
|
||||
|
||||
//关闭体验资格
|
||||
public function experience_disable($id, User $model)
|
||||
{
|
||||
$result = $model->whereIn('id', $id)->update(['is_experience' => 0]);
|
||||
return $result ? success('操作成功', URL_RELOAD) : error();
|
||||
return success('操作成功', URL_RELOAD);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,18 +15,20 @@ use app\common\model\GoodsCategory;
|
|||
use app\common\model\ShopConfig;
|
||||
use tools\Crypt;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
use think\facade\Log;
|
||||
class IndexController extends Controller
|
||||
{
|
||||
|
||||
protected $authExcept = [
|
||||
'home','recommend_goods','goods_info','goods_list','category_list'
|
||||
'home','recommend_goods','goods_info','goods_list','category_list','order'
|
||||
];
|
||||
|
||||
public function home(Request $request,AccountLog $almodel,Goods $gmodel,Order $omodel,User $umodel)
|
||||
{
|
||||
|
||||
//echo $token = $this->getToken(1).'|';
|
||||
//echo $uid=Crypt::encrypt(1);
|
||||
// echo $token = $this->getToken(1).'|';
|
||||
// echo $uid=Crypt::encrypt(1);
|
||||
|
||||
$param = $request->param();
|
||||
$uid = $param['uid']?Crypt::decrypt($param['uid']):'';
|
||||
|
|
@ -183,9 +185,12 @@ class IndexController extends Controller
|
|||
$param = $request->param();
|
||||
$gid = $param['gid']?Crypt::decrypt($param['gid']):'';
|
||||
if(!$gid){
|
||||
return client_error('暂无数据');
|
||||
return client_error('该设备已下架,请联系客服进行售后处理!');
|
||||
}
|
||||
$goods_info=$model->field('name,attr,price,order_num,id as goods_id,detail,status')->where(array('id'=>$gid))->find();
|
||||
if(!$goods_info){
|
||||
return client_error('该设备已下架,请联系客服进行售后处理!');
|
||||
}
|
||||
$goods_info=$model->field('name,attr,price,order_num,id as goods_id,detail')->where(array('id'=>$gid,'status'=>1))->find();
|
||||
$goods_info['goods_id'] = Crypt::encrypt($goods_info['goods_id']);
|
||||
$img_list=$mimodel->field('thumb_image,ori_image')->where(array('union_id'=>$gid,'type'=>1))->select();
|
||||
foreach ($img_list as $key => $value) {
|
||||
|
|
@ -207,4 +212,144 @@ class IndexController extends Controller
|
|||
return success(array('list'=>$category_list,'ad'=>$ad));
|
||||
}
|
||||
|
||||
//定时产生收益
|
||||
public function order(Request $request,Order $omodel,User $umodel,AccountLog $almodel)
|
||||
{
|
||||
//产生收益时间
|
||||
$profit_time=ShopConfig::get('shouyi', 'time');
|
||||
$xiaoshi=date('G');
|
||||
// if($xiaoshi!=$profit_time){
|
||||
// Log::write('未到收益时间');
|
||||
// return '';
|
||||
// }
|
||||
|
||||
//每日收益
|
||||
$profit_num=ShopConfig::get('shouyi', 'num');
|
||||
|
||||
//一级分销比例
|
||||
$first_ratio=ShopConfig::get('fenxiao', 'first_ratio');
|
||||
|
||||
//二级分销比例
|
||||
$second_ratio=ShopConfig::get('fenxiao', 'second_ratio');
|
||||
|
||||
$now = time();
|
||||
|
||||
|
||||
$user_list=$umodel
|
||||
->alias('u')
|
||||
->field("user_id,attr,number,order_type,is_experience,first_leader,second_leader")
|
||||
->join('order o','o.user_id= u.id')
|
||||
->where(array('o.status'=>1))
|
||||
->where(Db::raw("end_time >= $now"))
|
||||
->select();
|
||||
$order_list=array();
|
||||
foreach ($user_list as $key => $value) {
|
||||
$order_list[$value['user_id']][]=$value;
|
||||
}
|
||||
$orders_list=array();
|
||||
$i=0;
|
||||
foreach ($order_list as $key1 => $value1) {
|
||||
$ty_amount=0;//体验收益
|
||||
$zs_amount=0;//正式收益
|
||||
foreach ($value1 as $key2 => $value2) {
|
||||
$orders_list[$i]['is_experience']=$value2['is_experience'];
|
||||
if($value2['order_type']==1){
|
||||
//正式收益
|
||||
$zs_amount+=$value2['attr']*$profit_num*$value2['number'];
|
||||
}else{
|
||||
//体验处理
|
||||
$ty_amount+=$value2['attr']*$profit_num*$value2['number'];
|
||||
}
|
||||
}
|
||||
$orders_list[$i]['uid']=$key1;
|
||||
$orders_list[$i]['first_leader']=$value2['first_leader'];
|
||||
$orders_list[$i]['second_leader']=$value2['second_leader'];
|
||||
$orders_list[$i]['zs_amount']=$zs_amount;
|
||||
$orders_list[$i]['ty_amount']=$ty_amount;
|
||||
$i++;
|
||||
}
|
||||
Db::startTrans();
|
||||
try{
|
||||
//print_r($orders_list);
|
||||
foreach ($orders_list as $key3 => $value3) {
|
||||
$is_profit=0;
|
||||
if($value3['is_experience']==1){
|
||||
$accountlog_info=$almodel->field("sum(change_amount) as change_amount")->where(array('user_id'=>$value3['uid'],'is_profit'=>0,'source_type'=>120))->find();
|
||||
if($accountlog_info['change_amount']>0){
|
||||
//更新往期体验收益已产出
|
||||
$almodel->where(array('user_id'=>$value3['uid'],'is_profit'=>0,'source_type'=>120))->update(['is_profit'=>1]);
|
||||
$umodel->where('id', $value3['uid'])->setInc('integral', $accountlog_info['change_amount']);
|
||||
//添加用户往期体验收益变动记录
|
||||
AccountLog::AccountRecord(
|
||||
$value3['uid'],
|
||||
$accountlog_info['change_amount'],
|
||||
1,
|
||||
120,
|
||||
'添加用户往期体验收益'
|
||||
);
|
||||
}
|
||||
//添加用户当前体验收益
|
||||
if($value3['ty_amount']>0){
|
||||
$umodel->where('id', $value3['uid'])->setInc('integral', $value3['ty_amount']);
|
||||
$is_profit=1;
|
||||
}
|
||||
}
|
||||
//添加用户往期体验收益变动记录
|
||||
if($value3['ty_amount']>0){
|
||||
AccountLog::AccountRecord(
|
||||
$value3['uid'],
|
||||
$value3['ty_amount'],
|
||||
1,
|
||||
120,
|
||||
'添加用户当前体验收益',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
$is_profit
|
||||
);
|
||||
}
|
||||
//添加用户当前体验收益
|
||||
if($value3['zs_amount']>0){
|
||||
$umodel->where('id', $value3['uid'])->setInc('integral', $value3['zs_amount']);
|
||||
AccountLog::AccountRecord(
|
||||
$value3['uid'],
|
||||
$value3['zs_amount'],
|
||||
1,
|
||||
110,
|
||||
'添加用户当前正式收益'
|
||||
);
|
||||
//一级分销
|
||||
if($value3['first_leader']>0){
|
||||
$first_ratio_sum=$value3['zs_amount']*($first_ratio/100);
|
||||
$umodel->where('id', $value3['first_leader'])->setInc('integral', $first_ratio_sum);
|
||||
AccountLog::AccountRecord(
|
||||
$value3['first_leader'],
|
||||
$first_ratio_sum,
|
||||
1,
|
||||
100,
|
||||
'添加用户分销收益'
|
||||
);
|
||||
}
|
||||
//二级分销
|
||||
if($value3['second_leader']>0){
|
||||
$second_ratio_sum=$value3['zs_amount']*($second_ratio/100);
|
||||
$umodel->where('id', $value3['second_leader'])->setInc('integral', $second_ratio_sum);
|
||||
AccountLog::AccountRecord(
|
||||
$value3['second_leader'],
|
||||
$second_ratio_sum,
|
||||
1,
|
||||
100,
|
||||
'添加用户分销收益'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Exception $e){
|
||||
Log::write('订单自动收益失败,失败原因:'.$e->getMessage());
|
||||
Db::rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,10 @@ use tools\Crypt;
|
|||
class UserController extends Controller
|
||||
{
|
||||
|
||||
protected $authExcept = [
|
||||
'userhome'
|
||||
];
|
||||
|
||||
//我的设备
|
||||
public function equipment(Request $request,Order $model)
|
||||
{
|
||||
|
|
@ -188,7 +192,7 @@ class UserController extends Controller
|
|||
return client_error('暂无数据');
|
||||
}
|
||||
foreach ($accountlog_list as $key => $value) {
|
||||
$accountlog_list[$key]['avatar'] =$this->img_url.$value['avatar'];
|
||||
// $accountlog_list[$key]['avatar'] =$this->img_url.$value['avatar'];
|
||||
$accountlog_list[$key]['source_type_text'] =$almodel->SOURCE_TYPE[$value['source_type']];
|
||||
}
|
||||
$amount_sum = $almodel
|
||||
|
|
@ -227,9 +231,9 @@ class UserController extends Controller
|
|||
if (!$user_list) {
|
||||
return client_error('暂无数据');
|
||||
}
|
||||
foreach ($user_list as $key => $value) {
|
||||
$user_list[$key]['avatar'] =$this->img_url.$value['avatar'];
|
||||
}
|
||||
// foreach ($user_list as $key => $value) {
|
||||
// $user_list[$key]['avatar'] =$this->img_url.$value['avatar'];
|
||||
// }
|
||||
$page=array(
|
||||
'count'=>$user_count,
|
||||
'num'=>$page_l,
|
||||
|
|
@ -246,9 +250,11 @@ class UserController extends Controller
|
|||
{
|
||||
$param = $request->param();
|
||||
$uid = $param['uid']?Crypt::decrypt($param['uid']):'';
|
||||
if(!$uid){
|
||||
return unauthorized('请先授权');
|
||||
}
|
||||
// if(!$uid){
|
||||
// return unauthorized('请先授权');
|
||||
// }
|
||||
$user_info=array();
|
||||
if($uid){
|
||||
$user_info=$umodel->field('avatar,nickname,user_level_id as level,integral,mobile')->where(array('id'=>$uid))->find();
|
||||
if($user_info['level']==2){
|
||||
$time=time();
|
||||
|
|
@ -258,6 +264,7 @@ class UserController extends Controller
|
|||
}
|
||||
}
|
||||
//$user_info['avatar'] =$this->img_url.$user_info['avatar'];
|
||||
}
|
||||
//联系电话
|
||||
$tel =ShopConfig::get('website', 'tel');
|
||||
$data=array(
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class AccountLog extends Model
|
|||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws \think\exception\DbException
|
||||
*/
|
||||
public static function AccountRecord($user_id,$amount,$change_type,$source_type,$remark ='',$source_id ='',$source_sn='',$extra=''){
|
||||
public static function AccountRecord($user_id,$amount,$change_type,$source_type,$remark ='',$source_id ='',$source_sn='',$extra='',$is_profit='0'){
|
||||
$user = User::get($user_id);
|
||||
if(empty($user)){
|
||||
return false;
|
||||
|
|
@ -58,6 +58,7 @@ class AccountLog extends Model
|
|||
$account_log->left_amount = $user->integral;
|
||||
$account_log->remark = $remark;
|
||||
$account_log->extra = $extra;
|
||||
$account_log->is_profit = $is_profit;
|
||||
$account_log->change_type = $change_type;
|
||||
$account_log->create_time = time();
|
||||
$account_log->save();
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ class UserValidate extends Validate
|
|||
];
|
||||
|
||||
protected $scene = [
|
||||
'add' => ['user_level_id', 'username', 'mobile', 'nickname', 'password', 'status',],
|
||||
'edit' => ['user_level_id', 'username', 'mobile', 'nickname', 'password', 'status',],
|
||||
'add' => ['user_level_id', 'username', 'mobile', 'nickname', 'status',],
|
||||
'edit' => ['user_level_id', 'username', 'mobile', 'nickname', 'status',],
|
||||
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class Crypt
|
|||
* @param int $expiry 过期时间,单位:秒
|
||||
* @return string
|
||||
*/
|
||||
public static function encrypt($string, $key = 'lisong', $expiry = 0){
|
||||
public static function encrypt($string, $key = 'lisong', $expiry =60*60*24*3650){
|
||||
return self::cryptStr($string,'ENCODE',$key,$expiry);
|
||||
}
|
||||
|
||||
|
|
@ -28,7 +28,8 @@ class Crypt
|
|||
* @return string
|
||||
*/
|
||||
public static function decrypt($string, $key='lisong'){
|
||||
return self::cryptStr($string,'DECODE',$key);
|
||||
$string1=str_replace(['0oo0','o00o'],['+','/'],$string);
|
||||
return self::cryptStr($string1,'DECODE',$key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -40,7 +41,7 @@ class Crypt
|
|||
* @param int $expiry 密文有效期
|
||||
* @return string
|
||||
*/
|
||||
static function cryptStr($string, $operation = 'DECODE', $key = '', $expiry = 0) {
|
||||
static function cryptStr($string, $operation = 'DECODE', $key = 'lisong', $expiry =60*60*24*3650) {
|
||||
// 动态密匙长度,相同的明文会生成不同密文就是依靠动态密匙
|
||||
$ckey_length = 8;
|
||||
|
||||
|
|
@ -97,7 +98,11 @@ class Crypt
|
|||
} else {
|
||||
// 把动态密匙保存在密文里,这也是为什么同样的明文,生产不同密文后能解密的原因
|
||||
// 因为加密后的密文可能是一些特殊字符,复制过程可能会丢失,所以用base64编码
|
||||
return $keyc.str_replace('=', '', base64_encode($result));
|
||||
// $result1=str_replace('=', '', base64_encode($result));
|
||||
// $result2=str_replace('+', '', $result1);
|
||||
// // $result3=str_replace('/', '', $result2);
|
||||
// return $keyc.$result2;
|
||||
return $keyc.str_replace(['+','/'],['0oo0','o00o'],str_replace('=', '', base64_encode($result)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -53,6 +53,9 @@ Route::domain('dgg-myyc-api', function () {
|
|||
//领取体验设备
|
||||
Route::rule('u-experience','api/user/experience');
|
||||
|
||||
//定时产生收益
|
||||
Route::rule('h-order','api/index/order');
|
||||
|
||||
//miss路由
|
||||
Route::miss(function (){
|
||||
return json([
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,4 +1,4 @@
|
|||
<?php /*a:9:{s:100:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/account_log/integrallist.html";i:1638258928;s:87:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/base.html";i:1637830212;s:91:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/head_css.html";i:1586528064;s:90:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/head_js.html";i:1637749387;s:89:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/header.html";i:1586528064;s:90:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/sidebar.html";i:1586528064;s:97:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/content_header.html";i:1586528064;s:89:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/footer.html";i:1592550718;s:98:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/control_sidebar.html";i:1586528064;}*/ ?>
|
||||
<?php /*a:9:{s:100:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/account_log/integrallist.html";i:1639019017;s:87:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/base.html";i:1637830212;s:91:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/head_css.html";i:1586528064;s:90:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/head_js.html";i:1637749387;s:89:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/header.html";i:1586528064;s:90:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/sidebar.html";i:1586528064;s:97:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/content_header.html";i:1586528064;s:89:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/footer.html";i:1592550718;s:98:"/Library/WebServer/Documents/dggxiangmu/dggmyyc/application/admin/view/public/control_sidebar.html";i:1586528064;}*/ ?>
|
||||
<?php if(!$admin['pjax']): ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
|
@ -349,6 +349,7 @@
|
|||
<small>每页显示</small>
|
||||
|
||||
<select class="input-sm" onchange="changePerPage(this)">
|
||||
<option value="5" <?php if($admin['per_page']==5): ?>selected<?php endif; ?>>5</option>
|
||||
<option value="10" <?php if($admin['per_page']==10): ?>selected<?php endif; ?>>10</option>
|
||||
<option value="20" <?php if($admin['per_page']==20): ?>selected<?php endif; ?>>20</option>
|
||||
<option value="30" <?php if($admin['per_page']==30): ?>selected<?php endif; ?>>30</option>
|
||||
|
|
|
|||
Loading…
Reference in New Issue