初始化代码
This commit is contained in:
130
app/member/controller/AdminConfig.php
Normal file
130
app/member/controller/AdminConfig.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
namespace app\member\controller;
|
||||
use app\AdminRest;
|
||||
use app\member\model\Goods;
|
||||
use app\member\model\Level;
|
||||
use app\member\model\RightsRelation;
|
||||
use longbingcore\wxcore\WxSetting;
|
||||
use think\App;
|
||||
use app\member\model\Config as model;
|
||||
|
||||
|
||||
|
||||
class AdminConfig extends AdminRest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new model();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 11:21
|
||||
* @功能说明:会员配置详情
|
||||
*/
|
||||
public function configInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
|
||||
$data = $this->model->configInfo($dis);
|
||||
|
||||
if(!empty($data['commission_user'])){
|
||||
|
||||
$data['commission_user'] = array_values(explode(',',$data['commission_user']));
|
||||
|
||||
}
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$this->errorMsg('数据未找到');
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 13:24
|
||||
* @功能说明:配置编辑
|
||||
*/
|
||||
public function configUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid
|
||||
];
|
||||
|
||||
if(!empty($input['commission_user'])){
|
||||
|
||||
$input['commission_user'] = implode(',',$input['commission_user']);
|
||||
}
|
||||
// dump($input);exit;
|
||||
$data = $this->model->configUpdate($dis,$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-10 09:43
|
||||
* @功能说明:佣金下拉框
|
||||
*/
|
||||
public function commissionSelect(){
|
||||
|
||||
$level_model = new Level();
|
||||
|
||||
$dis = [
|
||||
|
||||
'status' => 1,
|
||||
|
||||
'uniacid'=> $this->_uniacid
|
||||
];
|
||||
|
||||
$level = $level_model->where($dis)->field(['top'=>'value','title'=>'name'])->select()->toArray();
|
||||
|
||||
$arr = [
|
||||
|
||||
['value'=>1000,'name'=>'全部'],
|
||||
|
||||
['value'=>888,'name'=>'员工'],
|
||||
|
||||
['value'=>777,'name'=>'普通用户'],
|
||||
|
||||
];
|
||||
|
||||
$arr = array_merge($arr,$level);
|
||||
|
||||
return $this->success($arr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
372
app/member/controller/AdminLevel.php
Normal file
372
app/member/controller/AdminLevel.php
Normal file
@@ -0,0 +1,372 @@
|
||||
<?php
|
||||
namespace app\member\controller;
|
||||
use app\AdminRest;
|
||||
use app\member\model\Coupon;
|
||||
use app\member\model\Goods;
|
||||
use app\member\model\Rights;
|
||||
use app\member\model\RightsRelation;
|
||||
use app\member\model\StoredLevel;
|
||||
use app\shop\model\AdminCoupon;
|
||||
use longbingcore\wxcore\PospalApi;
|
||||
use longbingcore\wxcore\WxSetting;
|
||||
use think\App;
|
||||
use app\member\model\Level as model;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class AdminLevel extends AdminRest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new model();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-26 16:48
|
||||
* @功能说明:远程同步会员等级
|
||||
*/
|
||||
public function synLevel(){
|
||||
|
||||
$api = new PospalApi();
|
||||
|
||||
$data = $api->getMemberLevel();
|
||||
|
||||
if($data['status']!='success'){
|
||||
|
||||
$this->errorMsg($data['messages'][0]);
|
||||
}
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as $k=> &$v){
|
||||
|
||||
$insert['uniacid'] = $this->_uniacid;
|
||||
|
||||
$insert['title'] = $v['name'];
|
||||
|
||||
$insert['discount']= $v['discount'];
|
||||
|
||||
$insert['is_point']= $v['isPoint'];
|
||||
|
||||
$insert['status'] = $v['enable'];
|
||||
|
||||
$insert['uid'] = $v['uid'];
|
||||
|
||||
$find = $this->model->where(['uid'=>$v['uid']])->find();
|
||||
|
||||
if(empty($find)){
|
||||
|
||||
$this->model->insert($insert);
|
||||
|
||||
}else{
|
||||
|
||||
$this->model->where(['uid'=>$v['uid']])->update($insert);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 10:49
|
||||
* @功能说明:会员等级列表
|
||||
*/
|
||||
public function levelList(){
|
||||
|
||||
$rights_model = new Rights();
|
||||
|
||||
$rights_model->initData($this->_uniacid);
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
// 'type' => $type
|
||||
];
|
||||
|
||||
$data = $this->model->levelList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-28 10:22
|
||||
* @功能说明:会员等级下拉框
|
||||
*/
|
||||
public function levelSelectV2(){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$data = $this->model->where($dis)->select()->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 11:21
|
||||
* @功能说明:会员等级详情
|
||||
*/
|
||||
public function levelInfo(){
|
||||
|
||||
// $rights_model = new Rights();
|
||||
|
||||
// $rights_model->initData($this->_uniacid);
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->model->levelInfo($dis);
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$this->errorMsg('数据未找到');
|
||||
}
|
||||
//权益模型
|
||||
$rights = new RightsRelation();
|
||||
//优惠券
|
||||
$coupon_model= new Coupon();
|
||||
|
||||
$dis = [
|
||||
|
||||
'member_id' => $data['id']
|
||||
];
|
||||
//优惠券
|
||||
$data['coupon'] = $coupon_model->where($dis)->select()->toArray();
|
||||
|
||||
$data['coupon'] = array_values($data['coupon']);
|
||||
|
||||
if(!empty($data['coupon'])){
|
||||
|
||||
$coupon_models = new \app\massage\model\Coupon();
|
||||
|
||||
foreach ($data['coupon'] as &$vs){
|
||||
|
||||
$vs['title'] = $coupon_models->where(['id'=>$vs['coupon_id']])->value('title');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// $dis['type'] = 1;
|
||||
//权益
|
||||
$data['rights'] = $rights->where($dis)->column('rights_id');
|
||||
|
||||
$data['rights'] = array_values($data['rights']);
|
||||
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 13:24
|
||||
* @功能说明:
|
||||
*/
|
||||
public function levelUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$data = $this->model->levelUpdate($dis,$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-17 13:42
|
||||
* @功能说明:会员商品
|
||||
*/
|
||||
public function memberGoods(){
|
||||
|
||||
$input = $this->_param;
|
||||
// //商品
|
||||
// $data['goods'] = $this->model->memberGoods($this->_uniacid,$input['id']);
|
||||
// //储值
|
||||
// $data['stored'] = $this->model->storedSelect($this->_uniacid,$input['id']);
|
||||
//自定义权益
|
||||
$data['rights'] = $this->model->memberRights($this->_uniacid,1);
|
||||
//默认权益
|
||||
$data['defult_rights'] = $this->model->memberRights($this->_uniacid);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-22 18:08
|
||||
* @功能说明:上下架
|
||||
*/
|
||||
|
||||
public function statusUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$input['status'] = $input['status']==1?0:1;
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$level = $this->model->levelInfo($dis);
|
||||
|
||||
if($level['type']==0){
|
||||
|
||||
$code = $this->model->checkStatus($input['id'],$input['status']);
|
||||
|
||||
if($code['code']!=200){
|
||||
|
||||
$this->errorMsg($code['msg']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->model->where($dis)->update($input);
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-29 09:58
|
||||
* @功能说明:等级下拉框
|
||||
*/
|
||||
public function levelSelect(){
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.uniacid' => $this->_uniacid,
|
||||
|
||||
'a.use_type'=> 1,
|
||||
|
||||
'c.status' => 1
|
||||
];
|
||||
|
||||
$model = new Rights();
|
||||
|
||||
$data = $model->goodsLevelSelect($dis);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-31 14:31
|
||||
* @功能说明:会员等级列表选择
|
||||
*/
|
||||
public function memberLevelSelect(){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'status' => 1
|
||||
|
||||
];
|
||||
|
||||
$data = $this->model->where($dis)->order('top')->select()->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-07 14:45
|
||||
* @功能说明:会员优惠券下拉框
|
||||
*/
|
||||
public function memberCouponSelect(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$coupon_model = new AdminCoupon();
|
||||
|
||||
$dis = [
|
||||
|
||||
'status' => 1,
|
||||
|
||||
'uniacid'=> $this->_uniacid,
|
||||
|
||||
'send_type'=>2
|
||||
];
|
||||
|
||||
$where = [];
|
||||
|
||||
if(!empty($input['title'])){
|
||||
|
||||
$where[] = ['title','like','%'.$input['title'].'%'];
|
||||
|
||||
}
|
||||
|
||||
$data = $coupon_model->where($dis)->where($where)->order('top desc')->paginate($input['limit'])->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
450
app/member/controller/AdminMember.php
Normal file
450
app/member/controller/AdminMember.php
Normal file
@@ -0,0 +1,450 @@
|
||||
<?php
|
||||
namespace app\member\controller;
|
||||
use app\AdminRest;
|
||||
use app\erp\model\OutOrder;
|
||||
use app\massage\model\BalanceWater;
|
||||
use app\massage\model\User;
|
||||
use app\member\info\PermissionMember;
|
||||
use app\member\model\Goods;
|
||||
use app\member\model\Member;
|
||||
use app\member\model\RightsRelation;
|
||||
use app\shop\controller\AdminSellingWater;
|
||||
use longbingcore\wxcore\Excel;
|
||||
use longbingcore\wxcore\WxSetting;
|
||||
use think\App;
|
||||
use app\member\model\Member as model;
|
||||
use app\member\model\Level;
|
||||
use app\member\model\Growth;
|
||||
use app\member\model\Integral;
|
||||
use app\member\model\StoredOrder;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class AdminMember extends AdminRest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $level_model;
|
||||
|
||||
protected $user_model;
|
||||
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new model();
|
||||
|
||||
$this->level_model = new Level();
|
||||
|
||||
$this->growth_model = new Growth();
|
||||
|
||||
$this->integral_model = new Integral();
|
||||
|
||||
$this->store_order_model = new StoredOrder();
|
||||
|
||||
$this->user_model = new User();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 10:49
|
||||
* @功能说明:会员列表
|
||||
*/
|
||||
|
||||
public function memberList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
// $this->model->memberInit($this->_uniacid);
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
//$member_growth = $this->level_model->memberGrowth($this->_uniacid);
|
||||
//创建时间搜索
|
||||
if(!empty($input['start_time'])&&!empty($input['end_time'])){
|
||||
|
||||
$start_time = $input['start_time'];
|
||||
|
||||
$end_time = $input['end_time'];
|
||||
|
||||
$dis[] = ['vip_time','between',"$start_time,$end_time"];
|
||||
}
|
||||
//等级搜索
|
||||
if(!empty($input['level'])){
|
||||
|
||||
$dis[] = ['member_level','=',$input['level']];
|
||||
|
||||
}else{
|
||||
|
||||
$dis[] = ['member_level','>',0];
|
||||
|
||||
}
|
||||
$where = [];
|
||||
//昵称搜索
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$where[] = ['nickName','like','%'.$input['name'].'%'];
|
||||
|
||||
$where[] = ['phone','like','%'.$input['name'].'%'];
|
||||
|
||||
$where[] = ['id','=',$input['name']];
|
||||
|
||||
|
||||
}
|
||||
//储值查询
|
||||
if(!empty($input['start_price'])&&!empty($input['end_price'])){
|
||||
|
||||
$start_price = $input['start_price'];
|
||||
|
||||
$end_price = $input['end_price'];
|
||||
|
||||
$dis[] = ['balance','between',"$start_price,$end_price"];
|
||||
|
||||
}
|
||||
|
||||
$data = $this->user_model->dataList($dis,$input['limit'],$where);
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
$level_model = new Level();
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$v['level_title'] = $level_model->where(['id'=>$v['member_level']])->value('title');
|
||||
|
||||
$list_form = $this->model->listForm($v['id']);
|
||||
|
||||
$v['order_price'] = $list_form['price'];
|
||||
|
||||
$v['order_count'] = $list_form['count'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 11:21
|
||||
* @功能说明:会员等级详情
|
||||
*/
|
||||
public function memberInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$level_model = new Level();
|
||||
|
||||
//用户信息
|
||||
$data['user_info'] = $this->user_model->dataInfo($dis);
|
||||
|
||||
$data['user_info']['level_title'] = $level_model->where(['id'=> $data['user_info']['member_level']])->value('title');
|
||||
//统计信息
|
||||
$data['form_list'] = $this->model->listForm($input['id']);
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $input['id'],
|
||||
|
||||
];
|
||||
|
||||
if($input['type']==1){
|
||||
//积分记录
|
||||
$data['data_list'] = $this->integral_model->integralList($dis,$input['limit']);
|
||||
|
||||
}elseif($input['type']==2){
|
||||
|
||||
$balance_model = new BalanceWater();
|
||||
//储值明细
|
||||
$data['data_list'] = $balance_model->indexList($dis,$input['limit']);
|
||||
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 13:24
|
||||
* @功能说明:
|
||||
*/
|
||||
public function statusUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$member = $this->model->getMemberInfo($dis);
|
||||
|
||||
$status = $member['status']==1?0:1;
|
||||
|
||||
$data = $this->model->memberUpdate($dis,['status'=>$status]);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-29 10:14
|
||||
* @功能说明:会员权限
|
||||
*/
|
||||
public function memberAuth(){
|
||||
|
||||
$persisson = new PermissionMember($this->_uniacid);
|
||||
|
||||
$auth = $persisson->pAuth();
|
||||
|
||||
return $this->success($auth);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-31 15:41
|
||||
* @功能说明:修改成长值
|
||||
*/
|
||||
public function updateGrowth(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$member = $this->model->memberInfo(['a.id'=>$input['id']]);
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'user_id' => $member['user_id'],
|
||||
|
||||
'controller' => $this->_user['admin_id'],
|
||||
|
||||
'growth_add' => $input['growth'],
|
||||
|
||||
'growth_before' => $member['growth'],
|
||||
|
||||
'growth_after' => $input['growth'],
|
||||
|
||||
'status' => 2,
|
||||
|
||||
'type' => 1,
|
||||
|
||||
'controller_type' => 1
|
||||
];
|
||||
//添加记录
|
||||
$this->growth_model->growthAdd($insert);
|
||||
|
||||
$order = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'user_id' => $member['user_id'],
|
||||
|
||||
'to_uid' => 0
|
||||
];
|
||||
//给用户修改成长值
|
||||
$res = $this->level_model->upUserRightsEnd(['growth'=>$input['growth']],$order);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* User: chenniang
|
||||
* Date: 2019-09-09 14:36
|
||||
* @return \think\Response
|
||||
* descption:佣金流水列表
|
||||
*/
|
||||
public function waterList(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$where = [];
|
||||
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$where[] = ['b.nickName','like',"%{$input['name']}%"];
|
||||
|
||||
$where[] = ['g.phone','like',"%{$input['name']}%"];
|
||||
}
|
||||
|
||||
if(!empty($input['thing_type'])){
|
||||
|
||||
$dis[] = ['a.thing_type','=',$input['thing_type']];
|
||||
|
||||
}
|
||||
|
||||
if(!empty($input['start_time'])&&!empty($input['end_time'])){
|
||||
|
||||
$start_time = $input['start_time'];
|
||||
|
||||
$end_time = $input['end_time'];
|
||||
|
||||
$dis[] = ['a.create_time','between',"$start_time,$end_time"];
|
||||
|
||||
}
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['a.thing_type','in',[1,2,3]];
|
||||
|
||||
$water_model = new \app\shop\model\AdminSellingWater();
|
||||
|
||||
$data = $water_model->storedWaterList($dis,$where,$this->_param['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-08-24 14:29
|
||||
* @功能说明:出库导出
|
||||
*/
|
||||
public function memberListExcel(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
$where1 = [];
|
||||
//创建时间搜索
|
||||
if(!empty($input['start_time'])&&!empty($input['end_time'])){
|
||||
|
||||
$start_time = $input['start_time'];
|
||||
|
||||
$end_time = $input['end_time'];
|
||||
|
||||
$dis[] = ['a.create_time','between',"$start_time,$end_time"];
|
||||
}
|
||||
//等级搜索
|
||||
if(!empty($input['level'])){
|
||||
|
||||
$growth_section = $this->level_model->getGrowth($input['level']);
|
||||
|
||||
$start_growth = $growth_section['start_growth'];
|
||||
|
||||
$end_growth = !empty($growth_section['end_growth'])?$growth_section['end_growth']-1:$growth_section['end_growth'];
|
||||
|
||||
$dis[] = !empty($end_growth)?['a.growth','between',"$start_growth,$end_growth"]:['a.growth','>',"$start_growth"];
|
||||
|
||||
}
|
||||
$where = [];
|
||||
//昵称搜索
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$where[] = ['b.nickName','like','%'.$input['name'].'%'];
|
||||
|
||||
$where[] = ['b.id','=',$input['name']];
|
||||
|
||||
}
|
||||
//储值查询
|
||||
if(!empty($input['start_price'])&&!empty($input['end_price'])){
|
||||
|
||||
$start_price = $input['start_price'];
|
||||
|
||||
$end_price = $input['end_price'];
|
||||
|
||||
$dis[] = ['a.stored','between',"$start_price,$end_price"];
|
||||
|
||||
}
|
||||
|
||||
$data = $this->model->memberList($dis,$where1,$where,100000000);
|
||||
|
||||
$name ='会员列表';
|
||||
|
||||
$header=[
|
||||
'ID',
|
||||
'手机号码',
|
||||
'用户昵称',
|
||||
'会员等级',
|
||||
'订单数量',
|
||||
'消费金额',
|
||||
'可用积分',
|
||||
'当前成长值',
|
||||
'储值余额',
|
||||
'成为会员时间',
|
||||
'会员有效期',
|
||||
|
||||
];
|
||||
|
||||
|
||||
$new_data = [];
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as $v){
|
||||
|
||||
if(!empty($v['level_content'])){
|
||||
|
||||
$over_time = !empty($v['over_time'])?date('Y-m-d H:i:s',$v['over_time']):'终生有效';
|
||||
}else{
|
||||
|
||||
$over_time = '';
|
||||
}
|
||||
|
||||
|
||||
$info = array();
|
||||
|
||||
$info[] = $v['id'];
|
||||
|
||||
$info[] = !empty($v['member_phone'])?$v['member_phone']:'';
|
||||
|
||||
$info[] = $v['nickName'];
|
||||
|
||||
$info[] = $v['level_content'];
|
||||
|
||||
$info[] = $v['order_num'];
|
||||
|
||||
$info[] = $v['price'];
|
||||
|
||||
$info[] = $v['integral'];
|
||||
|
||||
$info[] = $v['growth'];
|
||||
|
||||
$info[] = $v['stored'];
|
||||
|
||||
$info[] = !empty($v['level_content'])?date('Y-m-d H:i:s',$v['create_time']):'';
|
||||
|
||||
$info[] = $over_time;
|
||||
|
||||
$new_data[] = $info;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$excel_model = new Excel();
|
||||
//返回数据
|
||||
$fileName = $excel_model->excelExport($name,$header,$new_data);
|
||||
|
||||
return $this->success(1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
148
app/member/controller/AdminRights.php
Normal file
148
app/member/controller/AdminRights.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
namespace app\member\controller;
|
||||
use app\AdminRest;
|
||||
use app\member\model\Goods;
|
||||
use app\member\model\RightsRelation;
|
||||
use longbingcore\wxcore\WxSetting;
|
||||
use think\App;
|
||||
use app\member\model\Rights as model;
|
||||
|
||||
|
||||
|
||||
class AdminRights extends AdminRest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new model();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 10:49
|
||||
* @功能说明:权益列表
|
||||
*/
|
||||
public function rightsList(){
|
||||
|
||||
$this->model->initData($this->_uniacid);
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis[] = [
|
||||
|
||||
'uniacid' ,'=', $this->_uniacid
|
||||
];
|
||||
|
||||
$dis[] = ['status' ,'>', -1];
|
||||
|
||||
$data = $this->model->rightsList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 14:16
|
||||
* @功能说明:添加权益
|
||||
*/
|
||||
public function rightsAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$res = $this->model->rightsAdd($input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 11:21
|
||||
* @功能说明:权益详情
|
||||
*/
|
||||
public function rightsInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->model->rightsInfo($dis);
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$this->errorMsg('数据未找到');
|
||||
}
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 13:24
|
||||
* @功能说明:
|
||||
*/
|
||||
public function rightsUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->model->rightsUpdate($dis,$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 13:24
|
||||
* @功能说明:上下架
|
||||
*/
|
||||
public function rightsStatusUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->model->rightsUpdate($dis,$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
334
app/member/controller/AdminStored.php
Normal file
334
app/member/controller/AdminStored.php
Normal file
@@ -0,0 +1,334 @@
|
||||
<?php
|
||||
namespace app\member\controller;
|
||||
use app\AdminRest;
|
||||
|
||||
use app\member\model\CashRecord;
|
||||
use app\member\model\Member;
|
||||
use app\member\model\StoredCoupon;
|
||||
use app\member\model\StoredOrder;
|
||||
use longbingcore\wxcore\WxPay;
|
||||
use think\App;
|
||||
use app\member\model\Stored as model;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class AdminStored extends AdminRest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new model();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-09 10:35
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function storedList(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
|
||||
$data = $this->model->storedList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-09 10:41
|
||||
* @功能说明:储值添加
|
||||
*/
|
||||
public function storedAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$res = $this->model->storedAdd($input);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 11:21
|
||||
* @功能说明:会员配置详情
|
||||
*/
|
||||
public function storedInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->model->storedInfo($dis);
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$this->errorMsg('数据未找到');
|
||||
}
|
||||
|
||||
$coupon_model = new StoredCoupon();
|
||||
|
||||
$data['coupon'] = $coupon_model->where(['stored_id'=>$input['id']])->select()->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 13:24
|
||||
* @功能说明:配置编辑
|
||||
*/
|
||||
public function storedUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$data = $this->model->storedUpdate($dis,$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-09 13:39
|
||||
* @功能说明:下拉框
|
||||
*/
|
||||
public function storedSelect(){
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
|
||||
$data = $this->model->storedSelect($dis);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-16 11:09
|
||||
* @功能说明:员工扣款
|
||||
*/
|
||||
public function staffDeduction(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$member_model = new Member();
|
||||
//查看会员信息
|
||||
$member_info = $member_model->memberUpdateInfo(['user_id'=>$input['id']]);
|
||||
|
||||
$type = !empty($input['type'])?$input['type']:1;
|
||||
//判断余额
|
||||
if($input['price']>$member_info['stored']&&$type!=4){
|
||||
|
||||
$this->errorMsg('储值不足');
|
||||
}
|
||||
|
||||
$order_model = new StoredOrder();
|
||||
|
||||
$res = $order_model->desStore($input['price'],$input['content'],$member_info,$type,$this->_user['admin_id']);
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-12-01 11:23
|
||||
* @功能说明:用户提现记录
|
||||
*/
|
||||
public function userCashList()
|
||||
{
|
||||
$input = $this->_input;
|
||||
|
||||
$cash_model = new CashRecord();
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$dis[] = ['b.nickName','like','%'.$input['name'].'%'];
|
||||
}
|
||||
|
||||
|
||||
$data = $cash_model->dataList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-11-30 19:08
|
||||
* @功能说明:同意申请打款
|
||||
*/
|
||||
public function cashPass(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$cash_model = new CashRecord();
|
||||
|
||||
$record = $cash_model->dataInfo(['id'=>$input['id']]);
|
||||
|
||||
if($record['status']!=1){
|
||||
|
||||
$this->errorMsg('状态错误');
|
||||
}
|
||||
|
||||
$update = [
|
||||
|
||||
'status' => 2,
|
||||
|
||||
'hx_time'=> time(),
|
||||
|
||||
'hx_user'=> $this->_user['admin_id'],
|
||||
|
||||
'type' => $input['type']
|
||||
];
|
||||
Db::startTrans();
|
||||
|
||||
$res = $cash_model->where(['id'=>$input['id']])->update($update);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->errorMsg('审核失败');
|
||||
|
||||
}
|
||||
|
||||
if($input['type']==1){
|
||||
|
||||
$openid = Db::name('longbing_card_user')->where(['id'=>$record['user_id']])->value('openid');
|
||||
//微信相关模型
|
||||
$wx_pay = new WxPay($this->_uniacid);
|
||||
//微信提现
|
||||
$res = $wx_pay->crteateMchPay($openid,$record['true_price']);
|
||||
|
||||
if($res['result_code']=='SUCCESS'&&$res['return_code']=='SUCCESS'){
|
||||
//if(1==1){
|
||||
|
||||
}else{
|
||||
|
||||
Db::rollback();
|
||||
|
||||
return $this->error(!empty($res['err_code_des'])?$res['err_code_des']:'你还未该权限');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-11-30 19:08
|
||||
* @功能说明:不同意申请打款
|
||||
*/
|
||||
public function cashNoPass(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$cash_model = new CashRecord();
|
||||
|
||||
$record = $cash_model->dataInfo(['id'=>$input['id']]);
|
||||
|
||||
if($record['status']!=1){
|
||||
|
||||
$this->errorMsg('状态错误');
|
||||
}
|
||||
|
||||
$update = [
|
||||
|
||||
'status' => -1,
|
||||
|
||||
'hx_time'=> time(),
|
||||
|
||||
'hx_user'=> $this->_user['admin_id']
|
||||
|
||||
];
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$res = $cash_model->where(['id'=>$input['id']])->update($update);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
Db::rollback();
|
||||
|
||||
$this->errorMsg('审核失败');
|
||||
|
||||
}
|
||||
|
||||
$member_model= new Member();
|
||||
|
||||
$order_model = new StoredOrder();
|
||||
|
||||
$member_info = $member_model->memberUpdateInfo(['user_id'=>$record['user_id']]);
|
||||
|
||||
$record_id = $input['id'];
|
||||
//添加提现记录并且退还余额
|
||||
$res = $order_model->desStore($record['true_price'],'',$member_info,8,$this->_user['admin_id'],'',$record_id);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
$this->errorMsg('申请失败');
|
||||
}
|
||||
Db::commit();
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
275
app/member/controller/IndexMember.php
Normal file
275
app/member/controller/IndexMember.php
Normal file
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
namespace app\member\controller;
|
||||
use app\ApiRest;
|
||||
use app\massage\model\User;
|
||||
use app\member\info\PermissionMember;
|
||||
use app\member\model\Goods;
|
||||
use app\member\model\Growth;
|
||||
use app\member\model\Level;
|
||||
use app\member\model\Member;
|
||||
use app\member\model\Rights;
|
||||
use app\member\model\RightsRelation;
|
||||
use app\member\model\Config;
|
||||
use app\member\model\Stored;
|
||||
use app\member\model\StoredOrder;
|
||||
use think\App;
|
||||
use app\member\model\Member as model;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class IndexMember extends ApiRest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $config_model;
|
||||
|
||||
protected $level_model;
|
||||
|
||||
protected $rights_model;
|
||||
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new model();
|
||||
|
||||
$this->config_model = new Config();
|
||||
|
||||
$this->level_model = new Level();
|
||||
|
||||
$this->rights_model = new Rights();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-06 17:52
|
||||
* @功能说明:个人中心的会员信息
|
||||
*/
|
||||
public function userMember(){
|
||||
|
||||
$persisson = new PermissionMember($this->_uniacid);
|
||||
|
||||
$auth = $persisson->pAuth();
|
||||
|
||||
$config = $this->config_model->configInfo(['uniacid'=>$this->_uniacid]);
|
||||
//权限
|
||||
$data['auth'] = $config['status']==1?$auth:false;
|
||||
//会员等级
|
||||
$data['level'] = $this->level_model->getUserLevel($this->getUserId(),$this->_uniacid);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-28 09:41
|
||||
* @功能说明:会员信息
|
||||
*/
|
||||
public function memberInfo(){
|
||||
//用户会员相关信息
|
||||
$data['user_info'] = $this->model->userInfo($this->getUserId(),$this->_uniacid);
|
||||
//权益模型
|
||||
$rights_model = new Rights();
|
||||
//当前等级的id
|
||||
$level_id = !empty($data['user_info']['now_level']['id'])?$data['user_info']['now_level']['id']:0;
|
||||
//权益
|
||||
$data['rights'] = $rights_model->memberRights($level_id,$this->_uniacid);
|
||||
//配置
|
||||
$data['config'] = $this->config_model->configInfo(['uniacid'=>$this->_uniacid]);
|
||||
//plus会员
|
||||
$data['plus'] = $this->level_model->getPlusLvel($this->_uniacid);
|
||||
|
||||
$store_model = new Stored();
|
||||
|
||||
$goods_model = new Goods();
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
//储值套餐
|
||||
$store = $store_model->storedInfo($dis);
|
||||
|
||||
$data['is_store'] = !empty($store)?1:0;
|
||||
//可以购买的商品
|
||||
$can_bug = $goods_model->getCanBuyGoods($this->getUserId(),$this->_uniacid);
|
||||
|
||||
$data['is_goods'] = !empty($can_bug)?1:0;
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-28 15:26
|
||||
* @功能说明:等级详情
|
||||
*/
|
||||
public function levelInfo(){
|
||||
|
||||
$dis = [
|
||||
|
||||
'b.id' => $this->getUserId()
|
||||
|
||||
];
|
||||
$level_model = new Level();
|
||||
|
||||
$growth_model= new Growth();
|
||||
//用户信息
|
||||
$user_info = $this->model->memberInfoIndex($dis);
|
||||
//下一级会员等级
|
||||
$next_level = $level_model->getMemberLevel($this->_uniacid,$user_info['growth']);
|
||||
//下一等级的成长值
|
||||
$next_growth = !empty($next_level)?$next_level['growth']:$user_info['growth'];
|
||||
//当前数据
|
||||
$data['growth'][0] = [
|
||||
|
||||
'data' => $user_info['growth'],
|
||||
|
||||
'name' => '当前成长值',
|
||||
|
||||
'rate' => round($user_info['growth']/$next_growth*100,2)
|
||||
|
||||
];
|
||||
//下一级
|
||||
$data['growth'][1] = [
|
||||
|
||||
'data' => $next_growth-$user_info['growth'],
|
||||
|
||||
'name' => '升级',
|
||||
|
||||
'rate' => round(($next_growth-$user_info['growth'])/$next_growth*100,2)
|
||||
];
|
||||
//待结算金额
|
||||
$data['settled_growth'] = $growth_model->settledGrowth($this->_uniacid,$this->getUserId());
|
||||
//下级标题
|
||||
$data['next_level_title'] = !empty($next_level)?$next_level['title']:'';
|
||||
//配置
|
||||
$data['config'] = $this->config_model->configInfo(['uniacid'=>$this->_uniacid]);
|
||||
|
||||
$now_level = $level_model->getUserLevel($this->getUserId(),$this->_uniacid);
|
||||
|
||||
$data['top'] = !empty($now_level)?$now_level['top']:0;
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-28 16:59
|
||||
* @功能说明:会员等级列表
|
||||
*/
|
||||
public function levelList(){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'status' => 1,
|
||||
|
||||
];
|
||||
|
||||
$user_model = new User();
|
||||
//等级列表
|
||||
$data = $this->level_model->where($dis)->order('top')->select()->toArray();
|
||||
//当前等级
|
||||
$now_level = $user_model->where(['id'=>$this->getUserId()])->value('member_level');
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $k=>&$v){
|
||||
//下一级的成长值
|
||||
$v['next_growth'] = !empty($data[$k+1]['growth'])?$data[$k+1]['growth']:'';
|
||||
//当前等级
|
||||
$v['now_level'] = !empty($now_level)&&$v['id']==$now_level?1:0;
|
||||
//权益
|
||||
$v['rights'] = $this->rights_model->memberRights($v['id'],$v['uniacid']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$list['data'] = $data;
|
||||
//配置
|
||||
$list['config'] = $this->config_model->configInfo(['uniacid'=>$this->_uniacid]);
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-30 16:54
|
||||
* @功能说明:权益详情
|
||||
*/
|
||||
public function rightsInfo(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$data = $this->rights_model->rightsInfo(['id'=>$input['id']]);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-30 16:57
|
||||
* @功能说明:会员配置
|
||||
*/
|
||||
public function memberConfig(){
|
||||
|
||||
$data = $this->config_model->configInfo(['uniacid'=>$this->_uniacid]);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-10 17:52
|
||||
* @功能说明:会员二维码
|
||||
*/
|
||||
public function memberQr(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
// $qr = getCache($this->getUserId()."-member_qr",$this->_uniacid);
|
||||
|
||||
// if(empty($qr)){
|
||||
|
||||
$input['id'] = $this->getUserId();
|
||||
|
||||
$data = longbingCreateWxCode($this->_uniacid,$input,$input['page']);
|
||||
|
||||
$data = transImagesOne($data ,['qr_path'] ,$this->_uniacid);
|
||||
|
||||
$qr = $data['qr_path'];
|
||||
|
||||
// setCache($this->getUserId()."-member_qr",$qr,864000,$this->_uniacid);
|
||||
// }
|
||||
return $this->success($qr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
340
app/member/controller/IndexStored.php
Normal file
340
app/member/controller/IndexStored.php
Normal file
@@ -0,0 +1,340 @@
|
||||
<?php
|
||||
namespace app\member\controller;
|
||||
use app\ApiRest;
|
||||
use app\member\info\PermissionMember;
|
||||
use app\member\model\CashRecord;
|
||||
use app\member\model\Goods;
|
||||
use app\member\model\Growth;
|
||||
use app\member\model\Level;
|
||||
use app\member\model\Member;
|
||||
use app\member\model\Rights;
|
||||
use app\overlord\info\PermissionOverlord;
|
||||
use app\shop\model\ShareCouponId;
|
||||
use app\member\model\StoredOrder;
|
||||
use app\member\model\Config;
|
||||
use app\shop\model\ShareCoupon;
|
||||
use app\shop\controller\IndexWxPay;
|
||||
use app\shop\model\IndexCoupon;
|
||||
use think\App;
|
||||
use app\member\model\Stored as model;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class IndexStored extends ApiRest
|
||||
{
|
||||
|
||||
protected $model;
|
||||
|
||||
protected $config_model;
|
||||
|
||||
protected $level_model;
|
||||
|
||||
protected $rights_model;
|
||||
|
||||
protected $order_model;
|
||||
|
||||
protected $share_coupon_model;
|
||||
|
||||
|
||||
public function __construct(App $app) {
|
||||
|
||||
parent::__construct($app);
|
||||
|
||||
$this->model = new model();
|
||||
|
||||
$this->config_model = new Config();
|
||||
|
||||
$this->level_model = new Level();
|
||||
|
||||
$this->rights_model = new Rights();
|
||||
|
||||
$this->order_model = new StoredOrder();
|
||||
|
||||
$this->member_model = new Member();
|
||||
|
||||
$this->share_coupon_model = new ShareCoupon();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-10 17:44
|
||||
* @功能说明:储值列表
|
||||
*/
|
||||
public function storedList(){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$data = $this->model->storedList($dis,10);
|
||||
|
||||
$member_model = new Member();
|
||||
|
||||
$data['user_info'] = $member_model->userInfo($this->getUserId(),$this->_uniacid);
|
||||
|
||||
$overlord = new PermissionOverlord($this->_uniacid);
|
||||
|
||||
$data['user_info']['overlord_auth'] = $overlord->pAuth();
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-14 17:46
|
||||
* @功能说明:储值详情
|
||||
*/
|
||||
public function storedInfo(){
|
||||
|
||||
$input = $this->_param;
|
||||
|
||||
$dis = [
|
||||
|
||||
|
||||
'id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->model->storedInfo($dis);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-10 17:50
|
||||
* @功能说明:
|
||||
*/
|
||||
public function payOrder(){
|
||||
|
||||
$input = $this->_input;
|
||||
//分享人
|
||||
$share_id = !empty($input['share_id'])?$input['share_id']:0;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
|
||||
];
|
||||
|
||||
$data = $this->model->storedInfo($dis);
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$this->errorMsg('充值卡已下架');
|
||||
}
|
||||
//下单
|
||||
$order = $this->order_model->addOrder($data,$this->getUserId(),$input['staff_id'],$share_id);
|
||||
|
||||
$pay_controller = new IndexWxPay($this->app);
|
||||
|
||||
$user = $this->getUserInfo();
|
||||
//支付
|
||||
$jsApiParameters= $pay_controller->createWeixinPay($this->payConfig(),$user['openid'],$this->_uniacid,"储值充值",['type' => 'storedPay' , 'out_trade_no' => $order['order_code']],$order['pay_price']);
|
||||
|
||||
return $this->success($jsApiParameters);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-15 16:23
|
||||
* @功能说明:
|
||||
*/
|
||||
public function storedMemberInfo(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis= [
|
||||
|
||||
'b.id' => $input['id']
|
||||
];
|
||||
|
||||
$data = $this->member_model->memberInfoIndex($dis);
|
||||
//说明是plus会员
|
||||
if($data['over_time']>time()){
|
||||
|
||||
$data['member_title'] = $this->level_model->where(['top'=>999,'uniacid'=>$this->_uniacid])->value('title');
|
||||
|
||||
}else{
|
||||
//普通会员
|
||||
$level = $this->level_model->getUserLevel($input['id'],$this->_uniacid);
|
||||
|
||||
$data['member_title'] = !empty($level)?$level['title']:'';
|
||||
}
|
||||
//电话
|
||||
$data['member_phone'] = Db::name('longbing_card_user_phone')->where(['user_id'=>$input['id']])->value('phone');
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-16 11:09
|
||||
* @功能说明:员工扣款
|
||||
*/
|
||||
public function staffDeduction(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
if($this->getUserInfo()['is_staff']!=1){
|
||||
|
||||
$this->errorMsg('只有员工才能扣款哦');
|
||||
}
|
||||
|
||||
if(!isset($input['time'])||$input['time']+600<time()){
|
||||
|
||||
$this->errorMsg('支付码已过期,请重新生成');
|
||||
|
||||
}
|
||||
//查看会员信息
|
||||
$member_info = $this->member_model->memberUpdateInfo(['user_id'=>$input['id']]);
|
||||
//判断余额
|
||||
if($input['price']>$member_info['stored']){
|
||||
|
||||
$this->errorMsg('储值不足');
|
||||
}
|
||||
|
||||
$res = $this->order_model->desStore($input['price'],$input['content'],$member_info,2,$this->getUserId());
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-16 15:31
|
||||
* @功能说明:储值记录
|
||||
*/
|
||||
public function orderList(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['user_id','=',$this->getUserId()];
|
||||
|
||||
$dis[] = ['status','=',2];
|
||||
|
||||
if(!empty($input['title'])){
|
||||
|
||||
$dis[] = ['title','like','%'.$input['title'].'%'];
|
||||
|
||||
}
|
||||
|
||||
$data = $this->order_model->recordList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-11-30 18:32
|
||||
* @功能说明:申请提现
|
||||
*/
|
||||
public function applyTx(){
|
||||
|
||||
$input = $this->_input;
|
||||
//查看会员信息
|
||||
$member_info = $this->member_model->memberUpdateInfo(['user_id'=>$this->getUserId()]);
|
||||
//判断余额
|
||||
if($input['price']>$member_info['stored']||$input['price']>$member_info['cash_stored']){
|
||||
|
||||
$this->errorMsg('储值不足');
|
||||
}
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $this->_uniacid,
|
||||
|
||||
'user_id' => $this->getUserId(),
|
||||
|
||||
'apply_price' => $input['price'],
|
||||
|
||||
'true_price' => $input['price'],
|
||||
|
||||
'create_time' => time(),
|
||||
|
||||
'status' => 1,
|
||||
|
||||
'wx_code' => $input['wx_code']
|
||||
];
|
||||
|
||||
$cash_model = new CashRecord();
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
$res = $cash_model->insert($insert);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
$this->errorMsg('申请失败');
|
||||
}
|
||||
|
||||
$record_id = $cash_model->getLastInsID();
|
||||
//添加提现记录并且减掉余额
|
||||
$res = $this->order_model->desStore($insert['apply_price'],'',$member_info,7,$this->getUserId(),'',$record_id);
|
||||
|
||||
if($res!=1){
|
||||
|
||||
$this->errorMsg('申请失败');
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $this->success(1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-12-01 11:23
|
||||
* @功能说明:用户提现记录
|
||||
*/
|
||||
public function userCashList()
|
||||
{
|
||||
$input = $this->_input;
|
||||
|
||||
$cash_model = new CashRecord();
|
||||
|
||||
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['a.user_id','=',$this->getUserId()];
|
||||
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$dis[] = ['b.nickName','like','%'.$input['name'].'%'];
|
||||
}
|
||||
|
||||
$data = $cash_model->dataList($dis,$input['limit']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
615
app/member/info/AdminMenu.php
Normal file
615
app/member/info/AdminMenu.php
Normal file
@@ -0,0 +1,615 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:29
|
||||
*/
|
||||
$menu = <<<MENU
|
||||
[{
|
||||
"path": "vip/list",
|
||||
"name": "VipList",
|
||||
"component": "/application/vip/list",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "AppManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipList",
|
||||
"index": 0,
|
||||
"url": "/app/vip/list",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipApply",
|
||||
"index": 1,
|
||||
"url": "/app/vip/apply",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipLevel",
|
||||
"index": 2,
|
||||
"url": "/app/vip/level",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRight",
|
||||
"index": 3,
|
||||
"url": "/app/vip/right",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipSet",
|
||||
"index": 4,
|
||||
"url": "/app/vip/set",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipStoredSet",
|
||||
"index": 5,
|
||||
"url": "/app/vip/stored",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRecord",
|
||||
"index": 6,
|
||||
"url": "/app/vip/record",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "vip/apply",
|
||||
"name": "VipApply",
|
||||
"component": "/application/vip/apply",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "AppManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipList",
|
||||
"index": 0,
|
||||
"url": "/app/vip/list",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipApply",
|
||||
"index": 1,
|
||||
"url": "/app/vip/apply",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipLevel",
|
||||
"index": 2,
|
||||
"url": "/app/vip/level",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRight",
|
||||
"index": 3,
|
||||
"url": "/app/vip/right",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipSet",
|
||||
"index": 4,
|
||||
"url": "/app/vip/set",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipStoredSet",
|
||||
"index": 5,
|
||||
"url": "/app/vip/stored",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRecord",
|
||||
"index": 6,
|
||||
"url": "/app/vip/record",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "vip/level",
|
||||
"name": "VipLevel",
|
||||
"component": "/application/vip/level",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "AppManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipList",
|
||||
"index": 0,
|
||||
"url": "/app/vip/list",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipApply",
|
||||
"index": 1,
|
||||
"url": "/app/vip/apply",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipLevel",
|
||||
"index": 2,
|
||||
"url": "/app/vip/level",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRight",
|
||||
"index": 3,
|
||||
"url": "/app/vip/right",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipSet",
|
||||
"index": 4,
|
||||
"url": "/app/vip/set",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipStoredSet",
|
||||
"index": 5,
|
||||
"url": "/app/vip/stored",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRecord",
|
||||
"index": 6,
|
||||
"url": "/app/vip/record",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "vip/right",
|
||||
"name": "VipRight",
|
||||
"component": "/application/vip/right",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "AppManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipList",
|
||||
"index": 0,
|
||||
"url": "/app/vip/list",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipApply",
|
||||
"index": 1,
|
||||
"url": "/app/vip/apply",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipLevel",
|
||||
"index": 2,
|
||||
"url": "/app/vip/level",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRight",
|
||||
"index": 3,
|
||||
"url": "/app/vip/right",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipSet",
|
||||
"index": 4,
|
||||
"url": "/app/vip/set",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipStoredSet",
|
||||
"index": 5,
|
||||
"url": "/app/vip/stored",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRecord",
|
||||
"index": 6,
|
||||
"url": "/app/vip/record",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "vip/set",
|
||||
"name": "VipSet",
|
||||
"component": "/application/vip/set",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "AppManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipList",
|
||||
"index": 0,
|
||||
"url": "/app/vip/list",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipApply",
|
||||
"index": 1,
|
||||
"url": "/app/vip/apply",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipLevel",
|
||||
"index": 2,
|
||||
"url": "/app/vip/level",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRight",
|
||||
"index": 3,
|
||||
"url": "/app/vip/right",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipSet",
|
||||
"index": 4,
|
||||
"url": "/app/vip/set",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipStoredSet",
|
||||
"index": 5,
|
||||
"url": "/app/vip/stored",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRecord",
|
||||
"index": 6,
|
||||
"url": "/app/vip/record",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "vip/stored",
|
||||
"name": "VipStoredSet",
|
||||
"component": "/application/vip/stored",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "AppManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipList",
|
||||
"index": 0,
|
||||
"url": "/app/vip/list",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipApply",
|
||||
"index": 1,
|
||||
"url": "/app/vip/apply",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipLevel",
|
||||
"index": 2,
|
||||
"url": "/app/vip/level",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRight",
|
||||
"index": 3,
|
||||
"url": "/app/vip/right",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipSet",
|
||||
"index": 4,
|
||||
"url": "/app/vip/set",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipStoredSet",
|
||||
"index": 5,
|
||||
"url": "/app/vip/stored",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRecord",
|
||||
"index": 6,
|
||||
"url": "/app/vip/record",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "vip/record",
|
||||
"name": "VipRecord",
|
||||
"component": "/application/vip/record",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"title": "AppManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipList",
|
||||
"index": 0,
|
||||
"url": "/app/vip/list",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipApply",
|
||||
"index": 1,
|
||||
"url": "/app/vip/apply",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipLevel",
|
||||
"index": 2,
|
||||
"url": "/app/vip/level",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRight",
|
||||
"index": 3,
|
||||
"url": "/app/vip/right",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipSet",
|
||||
"index": 4,
|
||||
"url": "/app/vip/set",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipStoredSet",
|
||||
"index": 5,
|
||||
"url": "/app/vip/stored",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}, {
|
||||
"title": "VipRecord",
|
||||
"index": 6,
|
||||
"url": "/app/vip/record",
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "vip/detail",
|
||||
"name": "VipDetail",
|
||||
"component": "/application/vip/detail",
|
||||
"meta": {
|
||||
"title": "AppManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipDetail",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "vip/edit",
|
||||
"name": "VipLevelEdit",
|
||||
"component": "/application/vip/edit",
|
||||
"meta": {
|
||||
"title": "AppManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipLevelEdit",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "vip/editRight",
|
||||
"name": "VipRightEdit",
|
||||
"component": "/application/vip/editRight",
|
||||
"meta": {
|
||||
"title": "AppManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipRightEdit",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "vip/editStored",
|
||||
"name": "VipStoredEdit",
|
||||
"component": "/application/vip/editStored",
|
||||
"meta": {
|
||||
"title": "AppManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipStoredEdit",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}]
|
||||
MENU;
|
||||
|
||||
|
||||
$menus = <<<MENU
|
||||
|
||||
|
||||
|
||||
{
|
||||
"path": "/vip",
|
||||
"component": "Layout",
|
||||
"redirect": "/vip/list",
|
||||
"meta": {
|
||||
"menuName": "Vip",
|
||||
"icon": "iconMember",
|
||||
"subNavName": [{
|
||||
"name": "VipManage",
|
||||
"url": [{
|
||||
"name": "VipList",
|
||||
"url": "/vip/list"
|
||||
}, {
|
||||
"name": "VipApply",
|
||||
"url": "/vip/apply"
|
||||
}]
|
||||
}, {
|
||||
"name": "VipRecord",
|
||||
"url": [{
|
||||
"name": "VipRecord",
|
||||
"url": "/vip/record"
|
||||
}]
|
||||
}, {
|
||||
"name": "VipSet",
|
||||
"url": [{
|
||||
"name": "VipLevel",
|
||||
"url": "/vip/level"
|
||||
}, {
|
||||
"name": "VipRight",
|
||||
"url": "/vip/right"
|
||||
}, {
|
||||
"name": "VipSet",
|
||||
"url": "/vip/set"
|
||||
}, {
|
||||
"name": "VipStoredSet",
|
||||
"url": "/vip/stored"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
"children": [{
|
||||
"path": "list",
|
||||
"name": "VipManage",
|
||||
"component": "/application/vip/list",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "VipManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipList",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "apply",
|
||||
"name": "VipManage",
|
||||
"component": "/application/vip/apply",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "VipManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipApply",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "record",
|
||||
"name": "VipManage",
|
||||
"component": "/application/vip/record",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "VipManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipRecord",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "level",
|
||||
"name": "VipManage",
|
||||
"component": "/application/vip/level",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "VipManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipLevel",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "right",
|
||||
"name": "VipManage",
|
||||
"component": "/application/vip/right",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "VipManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipRight",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "set",
|
||||
"name": "VipManage",
|
||||
"component": "/application/vip/set",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "VipManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipSet",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "stored",
|
||||
"name": "VipManage",
|
||||
"component": "/application/vip/stored",
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"refresh": false,
|
||||
"title": "VipManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipStoredSet",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "detail",
|
||||
"name": "VipManage",
|
||||
"component": "/application/vip/detail",
|
||||
"meta": {
|
||||
"title": "VipManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipDetail",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "edit",
|
||||
"name": "VipManage",
|
||||
"component": "/application/vip/edit",
|
||||
"meta": {
|
||||
"title": "VipManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipLevelEdit",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "editRight",
|
||||
"name": "VipManage",
|
||||
"component": "/application/vip/editRight",
|
||||
"meta": {
|
||||
"title": "VipManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipRightEdit",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
"path": "editStored",
|
||||
"name": "VipManage",
|
||||
"component": "/application/vip/editStored",
|
||||
"meta": {
|
||||
"title": "VipManage",
|
||||
"isOnly": false,
|
||||
"auth": [],
|
||||
"pagePermission": [{
|
||||
"title": "VipStoredEdit",
|
||||
"index": 0,
|
||||
"auth": ["view", "add", "edit", "del", "outport"]
|
||||
}]
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
|
||||
MENU;
|
||||
|
||||
$app_name = config('app.AdminModelList')['app_model_name'];
|
||||
|
||||
$menu = $app_name=='longbing_member'?$menus:$menu;
|
||||
|
||||
|
||||
return ["member" => $menu];
|
||||
|
||||
|
||||
35
app/member/info/Info.php
Normal file
35
app/member/info/Info.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:30
|
||||
*/
|
||||
|
||||
|
||||
$app_name = config('app.AdminModelList')['app_model_name'];
|
||||
|
||||
$model = $app_name=='longbing_member'?'model':'app';
|
||||
return [
|
||||
|
||||
//模块名称[必填]
|
||||
'name' => 'member',
|
||||
//模块标题[必填]
|
||||
'title' =>'等级会员',
|
||||
//内容简介
|
||||
'desc' =>'新用户成本高?存量用户分层服务,最大化企业收益',
|
||||
//封面图标
|
||||
'icon' =>'data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAABTAAD/4QOJaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjYtYzEzOCA3OS4xNTk4MjQsIDIwMTYvMDkvMTQtMDE6MDk6MDEgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6OURDMDUxMzY2ODMxMTFFQTkzMDFBQjU5OTE3MDVEM0IiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MTc4NUQ2ODFEODgxMTFFQUE0NzhEMTBFREY1RDFGRTgiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MTc4NUQ2ODBEODgxMTFFQUE0NzhEMTBFREY1RDFGRTgiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTcgKFdpbmRvd3MpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6MmZkNWUzNzMtNzFkNS05ZjQyLTkyYWYtZWMwY2EwYmU4YjRkIiBzdFJlZjpkb2N1bWVudElEPSJhZG9iZTpkb2NpZDpwaG90b3Nob3A6MDY5OTM5YTUtODNiMy0xMWVhLTk0YTAtY2JjNzZlNGQ2OGMyIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+/+4ADkFkb2JlAGTAAAAAAf/bAIQAAgEBAQIBAgICAgMCAgIDAwMCAgMDBAMDAwMDBAUEBAQEBAQFBQYGBwYGBQgICQkICAwLCwsMDAwMDAwMDAwMDAECAgIEBAQIBQUICwkHCQsNDQ0NDQ0NDAwMDAwNDQwMDAwMDA0MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM/8AAEQgAPAA8AwERAAIRAQMRAf/EAJ8AAQACAwEBAAAAAAAAAAAAAAAICQUGBwQBAQEAAwADAQAAAAAAAAAAAAAAAgMGAQQFBxAAAQIEAwYDBQMNAAAAAAAAAQIDABEEBRIGByExIhMUCEEyFVFCFhcJklMYcWJyIzNjc4OTJEUoGREAAgECAwUFBAsAAAAAAAAAAAECEQMhBAUxQWESE/BRobEUcYHRBpHB4SIyQsLiQyQW/9oADAMBAAIRAxEAPwCXne93wZ9zvny52WyXN635LoHnKWlpaVxTQuYaVhVU1KkyK0uETQg7AmWzFMn6Xoui27NtSmqzeOO7gi2MSOsaAkIAQAgBAGWyZnrOeXb61c7FdKq0V7Bm3V0jy2XB7QSgiYO4g7CNhiq9YhcjyzSa4gmp/wBTLp+EzrZU/wAyOq9Kw8scnDyuZ6ryZYJYeHBu5m3Dg4Yxv+YXqqfxUr+3tu4kOTEgrG3JiAEAIAQAgBACZlACAM5prp9mPNefbTly0Nc243ipbp6ZJ8qSs8TiyNyUJBUo+ABinM5iNq25y2JBsuD0a0dyfkjTa1ZatLCBTW1lKHHy2lLlS+RN2odlvU4qaj7Nw2AR8kzmbneuOctr8OBS2bP0tN92n7IjrVZwOlpvu0/ZEKsESfqmdsFNetP0Z9s9KlN2y4jDektoAVVWwn9oqQ2qp1bf0CqflEav5Y1NwudGTwls4P7fMnBld8b8sEAIA2HSnUzNGTdRLTmazOJbuVoe5zGMYm1hSShxtY2EpWhSkmRnIxRmstG9bduWxhotv0M1+yfn/SWnzXZErcSptYrLYCF1NNWMpm5SqGwFUyMJ2YgQdxj5TnshOxd6cvp713lLVDC9rXddkvVHLte/R0rtnu9ofLN2sNSsLqKeZPLcBATiSqRG4EKBBG4m7U9LnlpJN1i9jDVD5kLu1yFmbuDvWQLLS1NcuwUrj1wvzeE0Cahl1DTlOCDOYK5YtxUCBsE4X9KuW8vG9JpczwW/2imBxb6mveJRWPLNXpzYXUu3q805bzFUJIUmht9Qkg0/8R9J2z8qD7VAj2PlvSHOSvz/AArZxff7F5koxK8435YIAQAgDr3Zt3VX/S3U1FZNdTl25ltnMVtSZ42QeF9oTlzWpkp9omnZOY8nWNLjmrdPzLY/q9jOJKpLfWbtT1DvGoSNUtDsx0ludzdQrRd5PFhmpbrkSXVMrDaxNYkpQICkrGMcW7K5PVLcLfp83FvleHCm7tuw2EE9zPLe6/I/a321mgo32btqHmfEsPYeF2pSnDzlJPEKemCpJB2rUfDErDKEZ6nmavC3Hy+L8BtZX/f79ebpe6u5XGpcrK+vecqKyrdViceedUVLWo+JJM43luCjFRiqJFh5IkBACAEAIA7/ANp31A9QtL8uVVjVbW8x2NxanqGheqVUy6J9fnLToQ5wLO1SCnftBBKp+Dqug28zJTryy8yLjU5drhrTnTP+pFfma+uhdXWEJZp0TDFJTInyqdlJnJKAfykzJmSTHqZLJwsW1bhsXjxOUqGox2jkQAgDK55ybfcu5yuliubJYuFoqnqSraPg4wsoJB8QZTBGwjaIqsXo3IKcdjVQYqLQIAQAgBACANq+Tmevk38ddIr0D1P0rqfHqOVzcWHfg93FuxbN8dX1kOt0q/epUVJf/VL/AAl+qjreq+ZPTt4fSuXh5MhyfVeZw+TyYf1ksM+DDGT+WPVUwp0uP6e1PeQhUgsZTjbExACAEAIA2rRv5N/HVJ8dep/D+L+59K5XUT93Fzfcn5sPFLdtjq5zrcj6VObiGWqf6v8A4Xf8b8rfTPzuj6Kf9Xm8z+bzf3kfMP7Pqd/Vr76/DwpwKcan/9k=',
|
||||
//模块类型[必填] model:模块 可以出现在左侧一级 app:应用中心 , 是一个应用中心的应用
|
||||
'type' => $model,
|
||||
//跳转链接[type=app时必填]
|
||||
'appUrl' => '/app/vip/list',
|
||||
// 模块唯一标识[必填],格式:模块名.开发者标识.module
|
||||
'identifier' => 'marketing.longbing.module',
|
||||
// 版本[必填],格式采用三段式:主版本号.次版本号.修订版本号
|
||||
'version' => '1.0.21',
|
||||
// 模块依赖[可选],格式[[模块名, 模块唯一标识, 依赖版本, 对比方式]]
|
||||
'need_module' => [],
|
||||
// 插件依赖[可选],格式[[插件名, 插件唯一标识, 依赖版本, 对比方式]]
|
||||
'need_plugin' => [],
|
||||
];
|
||||
127
app/member/info/PermissionMember.php
Normal file
127
app/member/info/PermissionMember.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace app\member\info;
|
||||
|
||||
use longbingcore\permissions\PermissionAbstract;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 模块功能权限
|
||||
* Class Permissionclosure
|
||||
*/
|
||||
class PermissionMember extends PermissionAbstract {
|
||||
|
||||
const tabbarKey = null;
|
||||
//后台管理菜单对应key[必填] , 当前模块文件夹名称
|
||||
const adminMenuKey = 'member';
|
||||
public $saasKey ;
|
||||
const apiPaths = [];
|
||||
|
||||
|
||||
public function __construct(int $uniacid,$infoConfigOptions = [])
|
||||
{
|
||||
$this->saasKey = longbing_get_auth_prefix('AUTH_MEMBER');
|
||||
|
||||
parent::__construct($uniacid, self::tabbarKey, self::adminMenuKey, $this->saasKey, self::apiPaths , $infoConfigOptions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 返回saas端授权结果
|
||||
* @return bool
|
||||
*/
|
||||
public function sAuth(): bool
|
||||
{
|
||||
|
||||
|
||||
|
||||
if(!$this->getAuthIsSaasCheck()){
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
return $this->sassValue > 0 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回p端授权结果
|
||||
* @return bool
|
||||
*/
|
||||
public function pAuth(): bool
|
||||
{
|
||||
|
||||
if (!$this->sAuth()) {
|
||||
return false;
|
||||
};
|
||||
|
||||
if(!$this->getAuthIsPlatformCheck()){
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
$pAuthConfig = $this->getPAuthConfig();
|
||||
|
||||
|
||||
|
||||
if (!$pAuthConfig || $pAuthConfig['member_switch'] == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$all_count = Db::name('longbing_cardauth2_auth_app')->where(['app_name'=>'member'])->count('count');
|
||||
} catch (\Exception $exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ($all_count > $this->getSaasValue()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
$cardauth2= Db::name('longbing_cardauth2_auth_app')->where(['modular_id' => $this->uniacid,'app_name'=>'member'])->find();
|
||||
} catch (\Exception $exception) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!$cardauth2|| $cardauth2['sign'] < time() || $cardauth2['count'] < 1||md5('ndvjnfjvnjnv'.$cardauth2['create_time'])==$cardauth2['sign_data']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回c端授权结果
|
||||
*
|
||||
* @param int $user_id
|
||||
* @return bool
|
||||
* @author ArtizanZhang
|
||||
* @DataTime: 2019/12/9 17:13
|
||||
*/
|
||||
public function cAuth(int $user_id): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
163
app/member/info/Subscribe.php
Normal file
163
app/member/info/Subscribe.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\member\info;
|
||||
|
||||
use app\card\service\UserService;
|
||||
use longbingcore\diy\BaseSubscribe;
|
||||
|
||||
/**
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/11 16:23
|
||||
* Class Subscribe
|
||||
* @package app\ucenter\info
|
||||
*/
|
||||
class Subscribe extends BaseSubscribe
|
||||
{
|
||||
|
||||
/**
|
||||
* 监听代理管理端授权小程序事件
|
||||
*
|
||||
* @param $data
|
||||
* @return array
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/27 17:33
|
||||
*/
|
||||
public function onAgentAppAuthEdit($config){
|
||||
|
||||
$permission = new PermissionMember(0);
|
||||
|
||||
if($permission->sAuth() && $permission->infoConfig['auth_platform'] ) {
|
||||
|
||||
$auth_switch['formType'] = 'radio';
|
||||
|
||||
$auth_switch['name'] = 'member_switch';
|
||||
|
||||
$auth_switch['value'] = $config ? $config[ $auth_switch['name'] ] : 0;
|
||||
|
||||
$auth_switch['title'] = $permission->info['title'];
|
||||
|
||||
return [ $auth_switch ];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 监听用户中心模块
|
||||
*
|
||||
* @return array
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/18 14:04
|
||||
*/
|
||||
// public function onAddUcenterCompoent(){
|
||||
// $last_staff_id = '#last_staff_id#' ;
|
||||
//
|
||||
// $moduleMenuShop = <<<COMPOENT
|
||||
//{
|
||||
// "title": "等级会员",
|
||||
// "type": "moduleMenuMember",
|
||||
// "icon": "iconMember",
|
||||
// "isDelete": true,
|
||||
// "addNumber": 1,
|
||||
// "attr": [{
|
||||
// "title": "模板名称",
|
||||
// "type": "Switch",
|
||||
// "name": "isShowTitle"
|
||||
// },
|
||||
// {
|
||||
// "title": "选择模板",
|
||||
// "type": "ChooseModule",
|
||||
// "name": "module",
|
||||
// "data": [{
|
||||
// "title": "一行多列",
|
||||
// "name": "module-menu-row",
|
||||
// "img": "http://longbingcdn.xiaochengxucms.com/admin/diy/module-menu-col.jpg"
|
||||
// },
|
||||
// {
|
||||
// "title": "一行一列",
|
||||
// "name": "module-menu-col",
|
||||
// "img": "http://longbingcdn.xiaochengxucms.com/admin/diy/module-menu-row.jpg"
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// "title": "一行多少列",
|
||||
// "type": "InputNumber",
|
||||
// "name": "row"
|
||||
// }
|
||||
// ],
|
||||
// "data": {
|
||||
// "isShowTitle": false,
|
||||
// "module": "module-menu-row",
|
||||
// "row": {
|
||||
// "number": 4,
|
||||
// "min": 2,
|
||||
// "max": 5,
|
||||
// "label": "请输入"
|
||||
// },
|
||||
// "list": [{
|
||||
// "title": "我的会员",
|
||||
// "icon": "iconMember",
|
||||
// "link": {
|
||||
// "type": 2,
|
||||
// "url": "/vip/pages/home"
|
||||
// }
|
||||
// }]
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//COMPOENT;
|
||||
//
|
||||
// $permission = new PermissionMember($this->_uniacid);
|
||||
// $compoentList = [] ;
|
||||
// if( $this->_uniacid == 0 || $permission->pAuth()){
|
||||
// $compoentList = [
|
||||
// json_decode($moduleMenuShop, true)
|
||||
// ] ;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// return $compoentList ;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param $item
|
||||
* @功能说明:监听支付菜单数据获取
|
||||
* @author jingshuixian
|
||||
* @DataTime: 2020/1/7 17:02
|
||||
*/
|
||||
// public function onDiyModuleMenuPayqr($item){
|
||||
// $last_staff_id = UserService::getLastStaffId($this->_uniacid,$this->getUserId()) ;
|
||||
//
|
||||
//
|
||||
// $list = [
|
||||
// [
|
||||
// "title" =>"去付款",
|
||||
// "icon" => "iconwodedingdan1",
|
||||
// "link"=> [
|
||||
// "type"=> 2,
|
||||
// "url"=> "/pay/pages/home?staff_id=".$last_staff_id
|
||||
// ]
|
||||
// ]
|
||||
// ] ;
|
||||
// $item['data']['list'] = $list ;
|
||||
// return $item;
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
166
app/member/info/UpdateSql.php
Normal file
166
app/member/info/UpdateSql.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
//获取表前缀
|
||||
$prefix = longbing_get_prefix();
|
||||
|
||||
//每个一个sql语句结束,都必须以英文分号结束。因为在执行sql时,需要分割单个脚本执行。
|
||||
//表前缀需要自己添加{$prefix} 以下脚本被测试脚本
|
||||
|
||||
|
||||
$sql = <<<updateSql
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `{$prefix}longbing_card_v2_member_config` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uniacid` int(11) DEFAULT NULL,
|
||||
`status` int(11) DEFAULT '0' COMMENT '会员开关',
|
||||
`growth_title` varchar(255) DEFAULT '' COMMENT '成长值名称',
|
||||
`growth_cash` varchar(11) DEFAULT '0' COMMENT '消费多少元增加成长值',
|
||||
`growth_order` varchar(11) DEFAULT '0' COMMENT '每笔订单增加多少',
|
||||
`growth_balance` varchar(11) DEFAULT '0' COMMENT '储值增加多少',
|
||||
`growth_limit` int(11) DEFAULT '0' COMMENT '储值开关',
|
||||
`growth_day_max` int(11) DEFAULT '0' COMMENT '每日最多增加多少',
|
||||
`integral_title` varchar(255) DEFAULT '' COMMENT '积分展示名称',
|
||||
`integral_cash` varchar(11) DEFAULT '0' COMMENT '每消费一元获得多少积分',
|
||||
`integral_limit` int(11) DEFAULT '0' COMMENT '积分限制',
|
||||
`integral_day_max` varchar(11) DEFAULT '0' COMMENT '每日最多获取多少积分',
|
||||
`explain` text COMMENT '说明',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='会员设置';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `{$prefix}longbing_card_v2_member_growth` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uniacid` int(11) DEFAULT NULL,
|
||||
`user_id` int(11) DEFAULT '0' COMMENT '用户id',
|
||||
`controller` varchar(128) DEFAULT '0' COMMENT '操作者',
|
||||
`growth_add` int(11) DEFAULT '0' COMMENT '新增成长值',
|
||||
`growth_before` int(11) DEFAULT '0' COMMENT '当前成长值',
|
||||
`growth_after` int(11) DEFAULT '0' COMMENT '修改后的成长值',
|
||||
`is_del` int(11) DEFAULT '0' COMMENT '是否清空',
|
||||
`is_member` int(11) DEFAULT '0' COMMENT '成为会员',
|
||||
`status` int(11) DEFAULT '1' COMMENT '状态',
|
||||
`create_time` int(11) DEFAULT '0' COMMENT '创建时间',
|
||||
`order_id` int(11) DEFAULT '0' COMMENT '订单状态',
|
||||
`goods_id` int(11) DEFAULT '0' COMMENT '商品id',
|
||||
`type` int(11) DEFAULT '1' COMMENT '类型',
|
||||
`controller_type` int(11) DEFAULT '0' COMMENT '操作类型',
|
||||
`update_time` int(11) DEFAULT '0',
|
||||
`refund` int(11) DEFAULT '0' COMMENT '是否退款',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `{$prefix}longbing_card_v2_member_integral` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uniacid` int(11) DEFAULT NULL,
|
||||
`user_id` int(11) DEFAULT '0' COMMENT '用户id',
|
||||
`controller` int(11) DEFAULT '0' COMMENT '操作者',
|
||||
`integral_add` int(11) DEFAULT '0' COMMENT '增减积分',
|
||||
`integral_before` int(11) DEFAULT '0' COMMENT '当前积分',
|
||||
`create_time` int(11) DEFAULT '0',
|
||||
`status` int(11) DEFAULT '0',
|
||||
`integral_after` int(11) DEFAULT '0',
|
||||
`order_id` int(11) DEFAULT '0' COMMENT '订单id',
|
||||
`type` int(11) DEFAULT '0',
|
||||
`controller_type` int(11) DEFAULT '0',
|
||||
`update_time` int(11) DEFAULT '0',
|
||||
`refund` int(11) DEFAULT '0',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `{$prefix}longbing_card_v2_member_level` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uniacid` int(11) DEFAULT NULL,
|
||||
`title` varchar(11) DEFAULT '' COMMENT '等级名字',
|
||||
`color` varchar(32) DEFAULT '0' COMMENT '背景颜色',
|
||||
`growth` int(11) DEFAULT '0' COMMENT '成长值',
|
||||
`discount` varchar(11) DEFAULT '0' COMMENT '消费折扣',
|
||||
`integral` varchar(11) DEFAULT '0' COMMENT '积分回馈倍率',
|
||||
`send_integral` varchar(11) DEFAULT '0' COMMENT '赠送积分',
|
||||
`is_goods` int(11) DEFAULT '0' COMMENT '买商品赠送会员开关',
|
||||
`status` int(11) DEFAULT '0',
|
||||
`create_time` int(11) DEFAULT '0',
|
||||
`update_time` int(11) DEFAULT '0',
|
||||
`top` int(11) DEFAULT '0' COMMENT '会员等级',
|
||||
`discount_switch` int(11) DEFAULT '0' COMMENT '消费折扣开关',
|
||||
`integral_switch` int(11) DEFAULT '0' COMMENT '积分回馈倍率开关',
|
||||
`send_integral_switch` int(11) DEFAULT '0' COMMENT '赠送积分开关',
|
||||
`upgrade_integral` int(11) DEFAULT '0' COMMENT '升级赠送积分',
|
||||
`upgrade_integral_switch` int(11) DEFAULT '0' COMMENT '升级赠送积分开关',
|
||||
`custom_rights_switch` int(11) DEFAULT '0' COMMENT '自定义权限开关',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='会员等级表';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `{$prefix}longbing_card_v2_member_list` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uniacid` int(11) DEFAULT NULL,
|
||||
`user_id` int(11) DEFAULT NULL,
|
||||
`create_time` int(11) DEFAULT '0' COMMENT '创建时间',
|
||||
`growth` int(11) DEFAULT '0' COMMENT '成长值',
|
||||
`status` int(11) DEFAULT '1' COMMENT '状态',
|
||||
`update_time` int(11) DEFAULT '0' COMMENT '更新时间',
|
||||
`integral` int(11) DEFAULT '0' COMMENT '会员积分',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `{$prefix}longbing_card_v2_member_rights` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uniacid` int(11) DEFAULT NULL,
|
||||
`title` varchar(225) DEFAULT '' COMMENT '权益名称',
|
||||
`show_title` varchar(255) DEFAULT '' COMMENT '展示名称',
|
||||
`icon` varchar(255) DEFAULT '' COMMENT '标志',
|
||||
`content` text COMMENT '简介',
|
||||
`top` int(11) DEFAULT '0' COMMENT '排序',
|
||||
`type` int(11) DEFAULT '0' COMMENT '服务方式',
|
||||
`status` int(11) DEFAULT '0',
|
||||
`create_time` int(11) DEFAULT '0',
|
||||
`update_time` int(11) DEFAULT '0',
|
||||
`use_type` int(11) DEFAULT '0' COMMENT '类型(1商品打折,2积分倍率想,3积分赠送)',
|
||||
`is_up` int(11) DEFAULT '0' COMMENT '升级赠送礼包',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='会员权益表';
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `{$prefix}longbing_card_v2_member_rights_relation` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uniacid` int(11) DEFAULT NULL,
|
||||
`rights_id` int(11) DEFAULT '0' COMMENT '权益id',
|
||||
`member_id` int(11) DEFAULT '0' COMMENT '等级id',
|
||||
`type` int(11) DEFAULT '0' COMMENT '类型',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
ALTER TABLE `{$prefix}longbing_card_member_level` ADD COLUMN `coupon_switch` int(11) DEFAULT '0' COMMENT '优惠券开关';
|
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `{$prefix}longbing_card_v2_member_coupon` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`uniacid` int(11) DEFAULT NULL,
|
||||
`member_id` int(11) DEFAULT '0' COMMENT '等级的id',
|
||||
`coupon_id` int(11) DEFAULT '0' COMMENT '优惠券id',
|
||||
`num` int(11) DEFAULT '0' COMMENT '数量',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
updateSql;
|
||||
|
||||
|
||||
|
||||
|
||||
return $sql;
|
||||
64
app/member/model/CashRecord.php
Normal file
64
app/member/model/CashRecord.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class CashRecord extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'longbing_card_member_cash_record';
|
||||
|
||||
protected $resultSetType = 'collection';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_user b','a.user_id = b.id')
|
||||
->where($dis)
|
||||
->field('a.*,b.nickName,b.avatarUrl')
|
||||
->group('a.id')
|
||||
->order('a.id desc')
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-11-30 19:09
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
308
app/member/model/Config.php
Normal file
308
app/member/model/Config.php
Normal file
@@ -0,0 +1,308 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\commission\model\Cash;
|
||||
use app\commission\model\Water;
|
||||
use app\shop\model\IndexSellingProfit;
|
||||
use app\shop\model\IndexSellingWater;
|
||||
use think\facade\Db;
|
||||
|
||||
class Config extends BaseModel
|
||||
{
|
||||
//会员权益表
|
||||
protected $name = 'longbing_card_v2_member_config';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function configAdd($data){
|
||||
|
||||
$data['explain'] = !empty($data['explain'])?$data['explain']:'';
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function configInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$this->configAdd($dis);
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
}
|
||||
|
||||
$data['growth_title'] = !empty($data['growth_title'])?$data['growth_title']:'成长值';
|
||||
|
||||
$data['integral_title'] = !empty($data['integral_title'])?$data['integral_title']:'积分';
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:13
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function configUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-17 17:04
|
||||
* @功能说明:储值下单的分销
|
||||
*/
|
||||
public function storeOrderCommission($order){
|
||||
|
||||
$uniacid = $order['uniacid'];
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $uniacid
|
||||
];
|
||||
|
||||
$config = $this->configInfo($dis);
|
||||
|
||||
if(empty($order['share_id'])){
|
||||
|
||||
return true;
|
||||
}
|
||||
//查看是否有权限
|
||||
$auth = $this->userAuthCommission($uniacid,$order['share_id']);
|
||||
|
||||
if($auth==1){
|
||||
|
||||
$water_model = new IndexSellingWater();
|
||||
|
||||
$cash_model = new IndexSellingProfit();
|
||||
|
||||
$pay_price = $config['commission_price_type']==1?$config['commission_price']:round($config['commission_balance']*$order['pay_price']/100,2);
|
||||
|
||||
$data = [
|
||||
|
||||
'uniacid' => $order['uniacid'],
|
||||
|
||||
'source_id' => $order['user_id'],
|
||||
|
||||
'user_id' => $order['share_id'],
|
||||
|
||||
'goods_id' => $order['stored_id'],
|
||||
|
||||
'type' => 1,
|
||||
|
||||
'title' => $order['title'],
|
||||
|
||||
'img' => '',
|
||||
|
||||
'price' => $order['pay_price'],
|
||||
|
||||
'extract' => $config['commission_price_type']==1?0:$config['commission_balance'],
|
||||
|
||||
'waiting' => 2,
|
||||
|
||||
'status' => 1,
|
||||
|
||||
'goods_id' => $order['stored_id'],
|
||||
|
||||
'buy_number'=> 1,
|
||||
|
||||
'extract_cash' => $pay_price,
|
||||
|
||||
'selling_type' => $config['commission_price_type'],
|
||||
|
||||
'order_id' => $order['id'],
|
||||
|
||||
'thing_type'=> 1
|
||||
|
||||
];
|
||||
|
||||
$res = $water_model->waterAdd($data);
|
||||
|
||||
if($res == 1){
|
||||
|
||||
$id = $water_model->getLastInsID();
|
||||
|
||||
$water = $water_model->waterInfo(['id'=>$id]);
|
||||
|
||||
$cash_model->incOrDecCash($water);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-17 17:35
|
||||
* @功能说明:获取用户是否是不是有权限分销
|
||||
*/
|
||||
public function userAuthCommission($uniacid,$user_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $uniacid
|
||||
];
|
||||
|
||||
$config = $this->configInfo($dis);
|
||||
|
||||
$auth = 0;
|
||||
|
||||
if(in_array($config['commission_type'],[1,3])&&!empty($config['commission_user'])){
|
||||
//用户信息
|
||||
$user = Db::name('longbing_card_user')->where(['id'=>$user_id])->find();
|
||||
|
||||
$level_model = new Level();
|
||||
//用户的等级
|
||||
$user_level = $level_model->getUserLevel($user_id,$uniacid);
|
||||
|
||||
$user_level = !empty($user_level)?$user_level['top']:0;
|
||||
//可以获取佣金的角色
|
||||
$author = explode(',',$config['commission_user']);
|
||||
|
||||
foreach ($author as &$value){
|
||||
//所有
|
||||
if($value==1000){
|
||||
|
||||
$auth = 1;
|
||||
}
|
||||
//员工 或者用户
|
||||
if(($value==888&&$user['is_staff']==1||($value==777&&$user['is_staff']==0))){
|
||||
|
||||
$auth =1;
|
||||
}
|
||||
//会员等级
|
||||
if($value==$user_level){
|
||||
|
||||
$auth =1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $auth;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-18 09:22
|
||||
* @功能说明:人工扣款佣金
|
||||
*/
|
||||
public function controllerCommission($order){
|
||||
|
||||
$uniacid = $order['uniacid'];
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $uniacid
|
||||
];
|
||||
|
||||
$config = $this->configInfo($dis);
|
||||
|
||||
$top_id = Db::name('longbing_card_user')->where(['id'=>$order['user_id']])->value('pid');
|
||||
|
||||
if(in_array($config['commission_type'],[2,3])&&$config['commission_Manual_status']==1&&!empty($top_id)){
|
||||
|
||||
$water_model = new IndexSellingWater();
|
||||
|
||||
$cash_model = new IndexSellingProfit();
|
||||
|
||||
$pay_price = round($config['commission_Manual_balance']*$order['pay_price']/100,2);
|
||||
|
||||
$data = [
|
||||
|
||||
'uniacid' => $order['uniacid'],
|
||||
|
||||
'source_id' => $order['user_id'],
|
||||
|
||||
'user_id' => $top_id,
|
||||
|
||||
'goods_id' => $order['stored_id'],
|
||||
|
||||
'type' => 1,
|
||||
|
||||
'title' => $order['title'],
|
||||
|
||||
'img' => '',
|
||||
|
||||
'price' => $order['pay_price'],
|
||||
|
||||
'extract' => $config['commission_Manual_balance'],
|
||||
|
||||
'waiting' => 2,
|
||||
|
||||
'status' => 1,
|
||||
|
||||
'goods_id' => $order['stored_id'],
|
||||
|
||||
'buy_number'=> 1,
|
||||
|
||||
'extract_cash' => $pay_price,
|
||||
|
||||
'selling_type' => 0,
|
||||
|
||||
'order_id' => $order['id'],
|
||||
|
||||
'thing_type'=> $order['controller_type']==2?2:3
|
||||
|
||||
];
|
||||
|
||||
$res = $water_model->waterAdd($data);
|
||||
|
||||
if($res == 1){
|
||||
|
||||
$id = $water_model->getLastInsID();
|
||||
|
||||
$water = $water_model->waterInfo(['id'=>$id]);
|
||||
|
||||
$cash_model->incOrDecCash($water);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
105
app/member/model/Coupon.php
Normal file
105
app/member/model/Coupon.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\shop\model\IndexCouponRecord;
|
||||
use think\facade\Db;
|
||||
|
||||
class Coupon extends BaseModel
|
||||
{
|
||||
//会员权益表
|
||||
protected $name = 'longbing_card_v2_member_coupon';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-07 16:18
|
||||
* @功能说明:添加优惠券
|
||||
*/
|
||||
public function addCoupon($coupon, $level_id,$data){
|
||||
|
||||
$this->where(['member_id'=>$level_id])->delete();
|
||||
|
||||
if(!empty($coupon)){
|
||||
|
||||
array_walk($coupon, function ($value, $key) use (&$coupon, $level_id,$data) {
|
||||
|
||||
$coupon[$key] = [
|
||||
//等级id
|
||||
'member_id' => $level_id,
|
||||
|
||||
'uniacid' => $data['uniacid'],
|
||||
|
||||
'coupon_id' => $value['coupon_id'],
|
||||
|
||||
'num' => $value['num'],
|
||||
|
||||
];
|
||||
|
||||
});
|
||||
//添加
|
||||
$res = $this->saveAll($coupon);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-08 16:30
|
||||
* @功能说明:添加用户的优惠券
|
||||
*/
|
||||
public function insertCoupon($level,$order){
|
||||
|
||||
if($level['coupon_switch']!=1){
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.member_id' => $level['id']
|
||||
];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_coupon b','a.coupon_id = b.id')
|
||||
->where($dis)
|
||||
->group('a.coupon_id')
|
||||
->field('b.*,a.num as coupon_num')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$record_model = new IndexCouponRecord();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $coupon){
|
||||
|
||||
for ($i=0;$i<$coupon['coupon_num'];$i++){
|
||||
|
||||
if(!isset($order['staff_id'])&&isset($order['to_uid'])){
|
||||
|
||||
$order['staff_id'] = $order['to_uid'];
|
||||
}
|
||||
//领取优惠券
|
||||
$record_model->insertRecord($coupon,$order);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
172
app/member/model/DiscountGoods.php
Normal file
172
app/member/model/DiscountGoods.php
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\member\info\PermissionMember;
|
||||
use think\facade\Db;
|
||||
|
||||
class DiscountGoods extends BaseModel
|
||||
{
|
||||
//会员商品表
|
||||
protected $name = 'longbing_card_v2_shop_member_discount';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function goodsAdd($data,$uniacid,$goods_id){
|
||||
|
||||
$this->where(['goods_id'=>$goods_id])->delete();
|
||||
|
||||
foreach ($data as $k=>$v){
|
||||
|
||||
$data[$k]['uniacid'] = $uniacid;
|
||||
|
||||
$data[$k]['goods_id'] = $goods_id;
|
||||
|
||||
}
|
||||
|
||||
$res = $this->saveAll($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $goods_id
|
||||
* @功能说明:商品折扣
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-29 15:10
|
||||
*/
|
||||
|
||||
public function goodsDiscount($goods_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'goods_id' => $goods_id
|
||||
];
|
||||
|
||||
$data = $this->where($dis)->select()->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-30 17:06
|
||||
* @功能说明:用户会员的折扣
|
||||
*/
|
||||
public function userGoodsDiscount($goods_id,$user_id,$uniacid){
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->configInfo(['uniacid'=>$uniacid]);
|
||||
|
||||
$level_model = new Level();
|
||||
//会员当前的等级
|
||||
$user_level = $level_model->getUserLevel($user_id,$uniacid);
|
||||
|
||||
$member_id = !empty($user_level)?$user_level['id']:0;
|
||||
|
||||
$dis = [
|
||||
|
||||
'goods_id' => $goods_id,
|
||||
|
||||
'member_id'=> $member_id
|
||||
];
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
//折扣
|
||||
$discount = !empty($data)&&$config['status']==1?$data['discount']/10:1;
|
||||
|
||||
return $discount;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-03 17:39
|
||||
* @功能说明:是不是会员商品
|
||||
*/
|
||||
public function isMemberGoods($goods_id,$user_id,$uniacid){
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->configInfo(['uniacid'=>$uniacid]);
|
||||
|
||||
$level_model = new Level();
|
||||
//会员当前的等级
|
||||
$user_level = $level_model->getUserLevel($user_id,$uniacid);
|
||||
|
||||
$member_id = !empty($user_level)?$user_level['id']:0;
|
||||
|
||||
$dis = [
|
||||
|
||||
'goods_id' => $goods_id,
|
||||
|
||||
'member_id'=> $member_id
|
||||
];
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
//折扣
|
||||
$data = !empty($data)&&$config['status']==1?1:0;
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-10 11:45
|
||||
* @功能说明:会员商品
|
||||
*/
|
||||
public function isMember($is_member,$uniacid){
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->configInfo(['uniacid'=>$uniacid]);
|
||||
|
||||
$persisson = new PermissionMember($uniacid);
|
||||
|
||||
$auth = $persisson->pAuth();
|
||||
|
||||
return $auth==true&&$config['status']==1?$is_member:0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-02-01 10:57
|
||||
* @功能说明:会员折扣
|
||||
*/
|
||||
public function eventDiscount($where){
|
||||
//会员商品折扣
|
||||
$data['discount'] = $this->userGoodsDiscount($where['goods_id'],$where['user_id'],$where['uniacid']);
|
||||
//是不是会员折扣商品
|
||||
$data['is_goods_member'] = $this->isMemberGoods($where['goods_id'],$where['user_id'],$where['uniacid']);
|
||||
|
||||
$data['name'] = 'member_discount';
|
||||
|
||||
$data['member_discount'] = $data['discount'];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
350
app/member/model/Goods.php
Normal file
350
app/member/model/Goods.php
Normal file
@@ -0,0 +1,350 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\shop\model\IndexShopOrderGoods;
|
||||
use think\facade\Db;
|
||||
|
||||
class Goods extends BaseModel
|
||||
{
|
||||
//会员商品表
|
||||
protected $name = 'longbing_card_member_goods';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function goodsAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function levelInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $order
|
||||
* @功能说明:会员商品支付回调
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-29 15:59
|
||||
*/
|
||||
public function payResult($order){
|
||||
|
||||
if($order['is_member']==1){
|
||||
|
||||
$order_goods_model = new IndexShopOrderGoods();
|
||||
|
||||
$order_item = $order_goods_model->orderGoodsInfo([ 'order_id' => $order[ 'id' ] ]);
|
||||
|
||||
foreach ( $order_item as $index => $item ) {
|
||||
|
||||
if($item['is_member']==1){
|
||||
|
||||
$this->getGrowth($item['goods_id'],$order['id'],$order['uniacid'],$order['user_id']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $goods_id
|
||||
* @功能说明:获取会员商品对类型
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-14 09:31
|
||||
*/
|
||||
public function getGoodsType($goods_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.goods_id' => $goods_id
|
||||
|
||||
];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_member_level b','a.member_id = b.id')
|
||||
->where($dis)
|
||||
->field('b.*')
|
||||
->find();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-29 15:31
|
||||
* @功能说明:支付回调
|
||||
*/
|
||||
public function getGrowth($goods_id,$order_id,$uniacid,$user_id){
|
||||
|
||||
$member_model = new Member();
|
||||
|
||||
$growth_model = new Growth();
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.goods_id' => $goods_id
|
||||
|
||||
];
|
||||
|
||||
$growth = $this->alias('a')
|
||||
->join('longbing_card_member_level b','a.member_id = b.id')
|
||||
->where($dis)
|
||||
->value('growth');
|
||||
|
||||
if(is_numeric($growth)&&$growth>0){
|
||||
|
||||
$member_info = $member_model->getMemberInfo(['user_id'=>$user_id,'uniacid'=>$uniacid]);
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'growth_add' => $growth,
|
||||
|
||||
'growth_after' => $member_info['growth']+$growth,
|
||||
|
||||
'growth_before' => $member_info['growth'],
|
||||
|
||||
'create_time'=> time(),
|
||||
|
||||
'order_id' => $order_id,
|
||||
|
||||
'goods_id' => $goods_id,
|
||||
|
||||
'type' => 0
|
||||
|
||||
];
|
||||
|
||||
$growth_model->insert($insert);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-14 10:19
|
||||
* @功能说明:更新会员
|
||||
*/
|
||||
public function ordertypeUpdate($order){
|
||||
//普通会员
|
||||
if(!empty($order['level_top'])){
|
||||
|
||||
$this->giveOrderGrowth($order);
|
||||
}
|
||||
//pul会员
|
||||
if(!empty($order['over_time'])){
|
||||
|
||||
$member_model = new Member();
|
||||
//获取用户会员信息(没有则创建)
|
||||
$user_info = $member_model->memberUpdateInfo(['user_id'=>$order['user_id'],'uniacid'=>$order['uniacid']]);
|
||||
//1是plus会员,给会员过期时间
|
||||
if($user_info['over_time']<time()){
|
||||
|
||||
$time = strtotime("+".$order['over_time']."month");
|
||||
|
||||
}else{
|
||||
|
||||
$time = strtotime("+".$order['over_time']."month",$user_info['over_time']);
|
||||
|
||||
}
|
||||
//永久的plus会员
|
||||
if($order['over_time']==-1){
|
||||
|
||||
$time = -1;
|
||||
}
|
||||
|
||||
$row['over_time'] = $time;
|
||||
|
||||
$member_model->where(['id'=>$user_info['id']])->update($row);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-14 09:49
|
||||
* @功能说明:给会员对成长值
|
||||
*/
|
||||
|
||||
public function giveOrderGrowth($order){
|
||||
|
||||
$growth_model = new Growth();
|
||||
|
||||
$level_model = new Level();
|
||||
|
||||
$member_model = new Member();
|
||||
|
||||
$order_goods_model = new IndexShopOrderGoods();
|
||||
|
||||
$level_data = $level_model->where(['top'=>$order['level_top'],'uniacid'=>$order['uniacid']])->find();
|
||||
|
||||
if(!empty($level_data)){
|
||||
|
||||
$level_data = $level_data->toArray();
|
||||
//当前会员对信息
|
||||
$member_info = $member_model->getMemberInfo(['user_id'=>$order['user_id'],'uniacid'=>$order['uniacid']]);
|
||||
//子订单
|
||||
$order_item = $order_goods_model->orderGoodsInfo([ 'order_id' => $order[ 'id' ] ]);
|
||||
|
||||
foreach ( $order_item as $index => $item ) {
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $order['uniacid'],
|
||||
|
||||
'user_id' => $order['user_id'],
|
||||
|
||||
'growth_add' => $level_data['growth'],
|
||||
|
||||
'growth_after' => $member_info['growth']+$level_data['growth'],
|
||||
|
||||
'growth_before' => $member_info['growth'],
|
||||
|
||||
'create_time'=> time(),
|
||||
|
||||
'order_id' => $order['id'],
|
||||
|
||||
'goods_id' => $item['goods_id'],
|
||||
|
||||
'type' => 0
|
||||
|
||||
];
|
||||
|
||||
$growth_model->insert($insert);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-30 09:41
|
||||
* @功能说明:获取可以买的商品
|
||||
*/
|
||||
public function getCanBuyGoods($uid,$uniacid){
|
||||
|
||||
$level_model = new Level();
|
||||
|
||||
$level = $level_model->getUserLevel($uid,$uniacid);
|
||||
|
||||
$member_model = new Member();
|
||||
//看他是不是永久的plus会员
|
||||
if(!empty($level)&&$level['top']==999){
|
||||
|
||||
$over_time = $member_model->where(['user_id'=>$uid])->value('over_time');
|
||||
|
||||
if($over_time==-1){
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!empty($level)){
|
||||
|
||||
$top_level = $level_model->getSonLevel($level,$uniacid,1);
|
||||
|
||||
}else{
|
||||
|
||||
$top_level = $level_model->getAllLevel($uniacid);
|
||||
|
||||
}
|
||||
|
||||
if(!empty($top_level)){
|
||||
|
||||
$dis[] = ['a.member_id','in',$top_level];
|
||||
|
||||
$dis[] = ['a.uniacid','=',$uniacid];
|
||||
|
||||
$dis[] = ['b.is_member','=',1];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_goods b','a.goods_id = b.id')
|
||||
->where($dis)
|
||||
->column('b.id');
|
||||
|
||||
}
|
||||
|
||||
return !empty($data)?$data:[];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-30 13:48
|
||||
* @功能说明:获取商品的会员等级
|
||||
*/
|
||||
public function getGoodsLevel($goods_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.goods_id' => $goods_id
|
||||
|
||||
];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_member_level b','a.member_id = b.id')
|
||||
->where($dis)
|
||||
->field('b.*')
|
||||
->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
310
app/member/model/Growth.php
Normal file
310
app/member/model/Growth.php
Normal file
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class Growth extends BaseModel
|
||||
{
|
||||
//会员权益表
|
||||
protected $name = 'longbing_card_member_growth';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function growthAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-16 16:35
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function growthList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order(['update_time desc','id desc'])->paginate($page)->toArray();
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
if($v['controller_type']==0){
|
||||
|
||||
$v['controller_name'] = '系统核算';
|
||||
|
||||
$icon = $v['growth_add']>0?'+':'-';
|
||||
|
||||
$growth_add = $v['growth_add']>0?$v['growth_add']:$v['growth_add']*-1;
|
||||
|
||||
$refund = $v['refund']==1?'(已退款)':'';
|
||||
|
||||
$boj = $this->returnObj($v['type']);
|
||||
|
||||
$v['text'] = $boj.'成长值'.$icon.$growth_add.',现成长值 '.$v['growth_after'].$refund;
|
||||
|
||||
}else{
|
||||
|
||||
$v['controller_name'] = Db::name('longbing_admin')->where(['admin_id'=>$v['controller']])->value('account');
|
||||
|
||||
$v['text'] = '成长值'.$v['growth_before'].',修改为 '.$v['growth_after'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-14 15:17
|
||||
* @功能说明:返回一个对象
|
||||
*/
|
||||
public function returnObj($type){
|
||||
|
||||
|
||||
switch ($type){
|
||||
//购买会员商品
|
||||
case 0:
|
||||
return '购买会员获得';
|
||||
|
||||
break;
|
||||
//会员购买商品
|
||||
case 1:
|
||||
return '消费获得';
|
||||
|
||||
break;
|
||||
//购买储值套餐赠送
|
||||
case 2:
|
||||
return '购买储值套餐赠送';
|
||||
|
||||
break;
|
||||
default:
|
||||
return '消费获得';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function growthInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:13
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function growthUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-28 16:29
|
||||
* @功能说明:
|
||||
*/
|
||||
public function settledGrowth($uniacid,$user_id){
|
||||
|
||||
$dis[] = ['uniacid','=',$uniacid];
|
||||
|
||||
$dis[] = ['growth_add','>',0];
|
||||
|
||||
$dis[] = ['is_del','=',0];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
$dis[] = ['user_id','=',$user_id];
|
||||
|
||||
$dis[] = ['refund','=',0];
|
||||
|
||||
$data = $this->where($dis)->sum('growth_add');
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-04 10:21
|
||||
* @功能说明:每日领取的积分
|
||||
*/
|
||||
public function dayGrowth($user_id,$uniacid){
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->configInfo(['uniacid'=>$uniacid]);
|
||||
|
||||
if($config['growth_limit']==1){
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'refund' => 0,
|
||||
|
||||
'type' => 1
|
||||
];
|
||||
|
||||
$growth = $this->where($dis)->where('status','>',0)->whereDay('create_time')->sum('growth_add');
|
||||
|
||||
$re_growth = $config['growth_day_max'] - $growth;
|
||||
|
||||
$re_growth = $re_growth>0?$re_growth:0;
|
||||
|
||||
return intval($re_growth);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-04 10:47
|
||||
* @功能说明:增加用户的成长值记录
|
||||
*/
|
||||
public function addUserGrowth($uniacid,$user_id,$growth,$order_id = 0,$type=0,$status = 1){
|
||||
|
||||
if(!empty(intval($growth))){
|
||||
|
||||
$member_model = new Member();
|
||||
|
||||
$member_info = $member_model->getMemberInfo(['user_id'=>$user_id,'uniacid'=>$uniacid]);
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'growth_add' => intval($growth),
|
||||
|
||||
'growth_before' => intval($member_info['growth']),
|
||||
|
||||
'growth_after' => intval($member_info['growth']+$growth),
|
||||
|
||||
'order_id' => $order_id,
|
||||
|
||||
'type' => $type,
|
||||
|
||||
'status' => $status,
|
||||
|
||||
];
|
||||
|
||||
$res = $this->growthAdd($insert);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-04 11:07
|
||||
* @功能说明:给用户加成长值
|
||||
*/
|
||||
public function incUserGrowth($order_id,$user_id,$uniacid){
|
||||
|
||||
$member_model = new Member();
|
||||
|
||||
$dis = [
|
||||
|
||||
'order_id' => $order_id,
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$info = $this->where($dis)->select()->toArray();
|
||||
|
||||
if(!empty($info)){
|
||||
|
||||
foreach ($info as &$value){
|
||||
|
||||
$member_info = $member_model->getMemberInfo(['user_id'=>$user_id,'uniacid'=>$uniacid]);
|
||||
|
||||
$growth = $value['growth_add'];
|
||||
|
||||
$update = [
|
||||
//修改状态
|
||||
'status' => 2,
|
||||
//当前
|
||||
'growth_before' => intval($member_info['growth']),
|
||||
//修改后对
|
||||
'growth_after' => intval($member_info['growth']+$growth),
|
||||
|
||||
];
|
||||
|
||||
$this->growthUpdate(['id'=>$value['id']],$update);
|
||||
|
||||
if(is_numeric($growth)&&$growth>0){
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $user_id
|
||||
|
||||
];
|
||||
|
||||
$member_model->incDecGrowth($dis,$growth,'growth');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
440
app/member/model/Integral.php
Normal file
440
app/member/model/Integral.php
Normal file
@@ -0,0 +1,440 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\massage\model\User;
|
||||
use think\facade\Db;
|
||||
|
||||
class Integral extends BaseModel
|
||||
{
|
||||
//会员积分表
|
||||
protected $name = 'longbing_card_v2_shop_integral_log';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'create_time_text'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-04 13:57
|
||||
* @功能说明:
|
||||
*/
|
||||
public function getCreateTimeTextAttr($value,$data){
|
||||
|
||||
if(!empty($data['create_time'])){
|
||||
|
||||
return date('Y-m-d H:i:s',$data['create_time']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function integralAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-16 16:35
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function integralList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order(['update_time desc','id desc'])->paginate($page)->toArray();
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
if($v['controller_type']==0){
|
||||
|
||||
$v['controller_name'] = '系统核算';
|
||||
|
||||
$icon = $v['integral_add']>0?'+':'-';
|
||||
|
||||
$integral_add = $v['integral_add']>0?$v['integral_add']:$v['integral_add']*-1;
|
||||
|
||||
$text = $v['integral_add']>0?'增加积分':'使用积分';
|
||||
|
||||
$boj = $this->returnObj($v['type']);
|
||||
|
||||
$refund = $v['refund']==1?'(已退款)':'';
|
||||
|
||||
$v['text'] = $boj.$text.$icon.$integral_add.',现积分 '.$v['integral_after'].$refund;
|
||||
|
||||
$v['type_text'] = $boj;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-14 15:17
|
||||
* @功能说明:返回一个对象
|
||||
*/
|
||||
public function returnObj($type){
|
||||
|
||||
switch ($type){
|
||||
//购买会员商品
|
||||
case 0:
|
||||
return '升级会员';
|
||||
|
||||
break;
|
||||
//会员购买商品
|
||||
case 1:
|
||||
return '消费';
|
||||
|
||||
break;
|
||||
//购买储值套餐赠送
|
||||
case 2:
|
||||
return '购买储值套餐';
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
return '购买商城商品';
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
return '购买餐饮菜品';
|
||||
|
||||
break;
|
||||
|
||||
case 5://取消订单
|
||||
return '商城商品退款';
|
||||
|
||||
break;
|
||||
case 6://售后
|
||||
return '商城商品退款';
|
||||
|
||||
break;
|
||||
case 7://
|
||||
return '同步银豹';
|
||||
|
||||
break;
|
||||
case 8://
|
||||
return '报名活动';
|
||||
|
||||
break;
|
||||
case 9://
|
||||
return '购买赛车产品';
|
||||
|
||||
break;
|
||||
|
||||
case 10://
|
||||
return '购买商城商品';
|
||||
|
||||
break;
|
||||
case 11://
|
||||
return '购买餐饮商品';
|
||||
|
||||
break;
|
||||
default:
|
||||
return '消费';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function integralInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:13
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function integralUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-31 10:28
|
||||
* @功能说明:增加用户积分
|
||||
*/
|
||||
public function integralUserAdd($user_id,$integral,$uniacid,$status = 2,$type=0,$order_id=0){
|
||||
//积分倍率
|
||||
$arr = $this->pointDouble($user_id,$integral);
|
||||
|
||||
$integral = $arr['integral'];
|
||||
//查询单日获取积分是否超限
|
||||
$integral = $this->dayGetIntegral($user_id,$integral,$uniacid);
|
||||
|
||||
if(!empty(intval($integral))){
|
||||
|
||||
$member_model = new User();
|
||||
|
||||
$member_info = $member_model->dataInfo(['id'=>$user_id]);
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'integral_add' => intval($integral),
|
||||
|
||||
'integral_before'=> intval($member_info['integral']),
|
||||
|
||||
'integral_after' => intval($member_info['integral']+$integral),
|
||||
|
||||
'status' => $status,
|
||||
|
||||
'type' => $type,
|
||||
|
||||
'order_id' => $order_id,
|
||||
|
||||
'double' => $arr['double'],
|
||||
];
|
||||
|
||||
$res = $this->integralAdd($insert);
|
||||
|
||||
if($res==0){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$res = $member_model->dataUpdate(['id'=>$user_id],['integral'=>$insert['integral_after']]);
|
||||
|
||||
if($res==0){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**\
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-12 17:31
|
||||
* @功能说明:积分倍率
|
||||
*/
|
||||
public function pointDouble($user_id,$integral){
|
||||
|
||||
$user_model = new User();
|
||||
|
||||
$member_level = $user_model->where(['id'=>$user_id])->value('member_level');
|
||||
|
||||
$arr['double'] = 1;
|
||||
|
||||
$arr['integral'] = $integral;
|
||||
|
||||
if(empty($member_level)){
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
$level_model = new Level();
|
||||
|
||||
$level = $level_model->levelInfo(['id'=>$member_level]);
|
||||
|
||||
if(empty($level)){
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
if(empty($level['integral_switch'])){
|
||||
|
||||
return $arr;
|
||||
|
||||
}
|
||||
|
||||
$arr['double'] = $level['integral'];
|
||||
|
||||
$arr['integral'] = floor($level['integral']*$integral);
|
||||
|
||||
return $arr;
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-12 14:05
|
||||
* @功能说明:单天获得积分
|
||||
*/
|
||||
public function dayGetIntegral($user_id,$integral,$uniacid){
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->configInfo(['uniacid'=>$uniacid]);
|
||||
|
||||
if($config['integral_limit']==0){
|
||||
|
||||
return $integral;
|
||||
}
|
||||
|
||||
$dis[] = ['user_id','=',$user_id];
|
||||
|
||||
$dis[] = ['integral_add','>',0];
|
||||
//单日获取积分
|
||||
$integral_day = $this->where($dis)->whereDay('create_time')->sum('integral_add');
|
||||
//单日可获取最大积分
|
||||
$integral_day_max = $config['integral_day_max'];
|
||||
|
||||
$point = $integral_day_max-$integral_day;
|
||||
|
||||
if($point<=0){
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$point = $point-$integral>0?$integral:$point;
|
||||
|
||||
return $point;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-04 10:21
|
||||
* @功能说明:每日领取的积分
|
||||
*/
|
||||
public function dayIntegral($user_id,$uniacid){
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->configInfo(['uniacid'=>$uniacid]);
|
||||
|
||||
if($config['integral_limit']==1){
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'refund' => 0,
|
||||
|
||||
'type' => 1
|
||||
];
|
||||
|
||||
$integral = $this->where($dis)->where('status','>',0)->whereDay('create_time')->sum('integral_add');
|
||||
|
||||
$re_integral = $config['integral_day_max'] - $integral;
|
||||
|
||||
$re_integral = $re_integral>0?$re_integral:0;
|
||||
|
||||
return intval($re_integral);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-04 11:07
|
||||
* @功能说明:给用户加积分
|
||||
*/
|
||||
public function incUserIntegral($order_id,$user_id,$uniacid){
|
||||
|
||||
$dis = [
|
||||
|
||||
'order_id' => $order_id,
|
||||
|
||||
'status' => 1
|
||||
];
|
||||
|
||||
$info = $this->where($dis)->select()->toArray();
|
||||
|
||||
$member_model = new Member();
|
||||
|
||||
if(!empty($info)){
|
||||
|
||||
foreach ($info as $value){
|
||||
|
||||
$integral = $value['integral_add'];
|
||||
|
||||
$member_info = $member_model->getMemberInfo(['user_id'=>$user_id,'uniacid'=>$uniacid]);
|
||||
|
||||
$update = [
|
||||
//修改状态
|
||||
'status' => 2,
|
||||
//当前
|
||||
'integral_before' => intval($member_info['integral']),
|
||||
//修改后对
|
||||
'integral_after' => intval($member_info['integral']+$integral),
|
||||
|
||||
];
|
||||
|
||||
$this->integralUpdate(['id'=>$value['id']],$update);
|
||||
|
||||
if(is_numeric($integral)&&$integral>0){
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $user_id
|
||||
|
||||
];
|
||||
|
||||
$member_model->incDecGrowth($dis,$integral,'integral');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
739
app/member/model/Level.php
Normal file
739
app/member/model/Level.php
Normal file
@@ -0,0 +1,739 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\massage\model\User;
|
||||
use app\member\info\PermissionMember;
|
||||
use think\facade\Db;
|
||||
|
||||
class Level extends BaseModel
|
||||
{
|
||||
//会员等级表
|
||||
protected $name = 'longbing_card_v2_member_level';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function levelAdd($data){
|
||||
|
||||
$data['status'] = 1;
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$goods_id = [];
|
||||
|
||||
$rights = [];
|
||||
|
||||
$coupon = [];
|
||||
|
||||
$stored = [];
|
||||
//关联的商品
|
||||
if(isset($data['goods_id'])){
|
||||
|
||||
$goods_id = $data['goods_id'];
|
||||
|
||||
unset($data['goods_id']);
|
||||
}
|
||||
//关联的权益
|
||||
if(isset($data['rights'])){
|
||||
|
||||
$rights = $data['rights'];
|
||||
|
||||
unset($data['rights']);
|
||||
}
|
||||
//关联的优惠券
|
||||
if(isset($data['coupon'])){
|
||||
|
||||
$coupon = $data['coupon'];
|
||||
|
||||
unset($data['coupon']);
|
||||
}
|
||||
//关联储值
|
||||
if(isset($data['stored_id'])){
|
||||
|
||||
$stored = $data['stored_id'];
|
||||
|
||||
unset($data['stored_id']);
|
||||
}
|
||||
|
||||
$res = $this->insert($data);
|
||||
//id
|
||||
$level_id = $this->getLastInsID();
|
||||
//修改相关数据
|
||||
$this->updateSome($goods_id,$rights,$level_id,$data,$coupon,$stored);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-10 15:13
|
||||
* @功能说明:初始化
|
||||
*/
|
||||
public function initLevel($dis){
|
||||
|
||||
//初始化普通会员
|
||||
if($dis['type']==0){
|
||||
|
||||
for ($i=1;$i<11;$i++){
|
||||
|
||||
$insert[$i]['uniacid'] = $dis['uniacid'];
|
||||
|
||||
$insert[$i]['status'] = 0;
|
||||
|
||||
$insert[$i]['create_time'] = time();
|
||||
|
||||
$insert[$i]['update_time'] = time();
|
||||
|
||||
$insert[$i]['top'] = $i;
|
||||
}
|
||||
|
||||
$this->saveAll($insert);
|
||||
|
||||
}else{
|
||||
//初始化puls会员
|
||||
$insert['uniacid'] = $dis['uniacid'];
|
||||
|
||||
$insert['status'] = 0;
|
||||
|
||||
$insert['create_time'] = time();
|
||||
|
||||
$insert['update_time'] = time();
|
||||
|
||||
$insert['type'] = 1;
|
||||
|
||||
$insert['top'] = 999;
|
||||
|
||||
$insert['over_time'] = -1;
|
||||
|
||||
$this->insert($insert);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:12
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function levelList($dis,$page=10){
|
||||
|
||||
$data = $this->where($dis)->order('id')->paginate($page)->toArray();
|
||||
|
||||
$right_model = new Rights();
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$v['rights'] = $right_model->customRights($v['id']);
|
||||
//商品折扣
|
||||
if($v['discount_switch']==1){
|
||||
|
||||
array_unshift($v['rights'],'商品打折');
|
||||
|
||||
}
|
||||
//积分倍率
|
||||
if($v['integral_switch']==1){
|
||||
|
||||
array_unshift($v['rights'],'积分倍率'.$v['integral'].'倍');
|
||||
|
||||
}
|
||||
//赠送积分
|
||||
if($v['send_integral_switch']==1){
|
||||
|
||||
array_unshift($v['rights'],'赠送积分'.$v['send_integral']);
|
||||
|
||||
}
|
||||
// //赠送优惠券
|
||||
if($v['coupon_switch']==1){
|
||||
|
||||
array_unshift($v['rights'],'赠送卡券');
|
||||
|
||||
}
|
||||
|
||||
$user_model = new User();
|
||||
//会员人数
|
||||
$v['member_num'] = $user_model->where(['member_level'=>$v['id']])->count();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function levelInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:13
|
||||
* @功能说明:删除直播
|
||||
*/
|
||||
public function levelUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$goods_id = [];
|
||||
|
||||
$rights = [];
|
||||
|
||||
$coupon = [];
|
||||
|
||||
$stored = [];
|
||||
|
||||
//关联的权益
|
||||
if(isset($data['rights'])){
|
||||
|
||||
$rights = $data['rights'];
|
||||
|
||||
unset($data['rights']);
|
||||
}
|
||||
//关联的优惠券
|
||||
if(isset($data['coupon'])){
|
||||
|
||||
$coupon = $data['coupon'];
|
||||
|
||||
unset($data['coupon']);
|
||||
}
|
||||
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
$this->updateSome($rights,$data['id'],$data,$coupon);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $level_id
|
||||
* @param $data
|
||||
* @功能说明:修改相关数据
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 13:40
|
||||
*/
|
||||
public function updateSome($rights,$level_id,$data,$coupon=[]){
|
||||
|
||||
|
||||
//关联的商品模型
|
||||
$rights_model = new RightsRelation();
|
||||
|
||||
$rights_model->where(['member_id'=>$level_id])->delete();
|
||||
//添加关联的商品
|
||||
if(!empty($rights)){
|
||||
|
||||
array_walk($rights, function ($value, $key) use (&$rights, $level_id,$data) {
|
||||
|
||||
$rights[$key] = [
|
||||
//商品id
|
||||
'rights_id' => $value['id'],
|
||||
//等级id
|
||||
'member_id' => $level_id,
|
||||
|
||||
'uniacid' => $data['uniacid'],
|
||||
|
||||
'type' => $value['type']
|
||||
|
||||
];
|
||||
|
||||
});
|
||||
//添加
|
||||
$res = $rights_model->saveAll($rights);
|
||||
}
|
||||
//优惠券关联模型
|
||||
$coupon_model = new Coupon();
|
||||
//添加
|
||||
$coupon_model->addCoupon($coupon,$level_id,$data);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-16 11:08
|
||||
* @功能说明:获取成长值区间
|
||||
*/
|
||||
public function getGrowth($level){
|
||||
|
||||
$data = $this->where(['id'=>$level])->find();
|
||||
|
||||
$dis[]= ['uniacid','=',$data['uniacid']];
|
||||
|
||||
$dis[]= ['growth','>',$data['growth']];
|
||||
|
||||
$top = $this->where($dis)->order('growth')->find();
|
||||
|
||||
$info['start_growth'] = $data['growth'];
|
||||
|
||||
$info['end_growth'] = !empty($top['growth'])?$top['growth']:0;
|
||||
|
||||
return $info;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-17 13:22
|
||||
* @功能说明:会员商品
|
||||
*/
|
||||
public function memberGoods($uniacid,$level_id){
|
||||
|
||||
$dis[] = ['uniacid','=',$uniacid];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
$dis[] = ['is_member','=',1];
|
||||
|
||||
$id = $this->haveSelectGoods($uniacid,$level_id);
|
||||
|
||||
$dis[] = ['id','not in',$id];
|
||||
|
||||
$data = Db::name('longbing_card_goods')->where($dis)->field('name,id')->select();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-09 13:39
|
||||
* @功能说明:下拉框
|
||||
*/
|
||||
public function storedSelect($uniacid,$level_id){
|
||||
|
||||
$id = $this->haveSelectStored($uniacid,$level_id);
|
||||
|
||||
$dis[] = ['uniacid','=',$uniacid];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
$dis[] = ['id','not in',$id];
|
||||
|
||||
$data = Db::name('longbing_card_member_stored')->where($dis)->order('top desc,id desc')->select()->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-09 14:09
|
||||
* @功能说明:已经选了储值
|
||||
*/
|
||||
|
||||
public function haveSelectStored($uniacid,$level_id){
|
||||
|
||||
$dis[] = ['a.uniacid','=',$uniacid];
|
||||
|
||||
$dis[] = ['b.uniacid','=',$uniacid];
|
||||
|
||||
$dis[] = ['a.member_id','<>',$level_id];
|
||||
|
||||
$store_level_model = new StoredLevel();
|
||||
|
||||
$id = $store_level_model->alias('a')
|
||||
->join('longbing_card_member_level b','a.member_id = b.id')
|
||||
->where($dis)
|
||||
->column('a.stored_id');
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-06 15:21
|
||||
* @功能说明:已经选了的商品
|
||||
*/
|
||||
public function haveSelectGoods($uniacid,$level_id){
|
||||
|
||||
$dis[] = ['a.uniacid','=',$uniacid];
|
||||
|
||||
$dis[] = ['b.uniacid','=',$uniacid];
|
||||
|
||||
$dis[] = ['a.member_id','<>',$level_id];
|
||||
|
||||
$goods_model = new Goods();
|
||||
|
||||
$id = $goods_model->alias('a')
|
||||
->join('longbing_card_member_level b','a.member_id = b.id')
|
||||
->where($dis)
|
||||
->column('goods_id');
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $uniacid
|
||||
* @功能说明:会员权益
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-22 14:23
|
||||
*/
|
||||
public function memberRights($uniacid,$type = 0){
|
||||
|
||||
$dis[] = ['uniacid','=',$uniacid];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
$dis[] = ['type','=',$type];
|
||||
|
||||
$rights_model = new Rights();
|
||||
|
||||
$data = $rights_model->where($dis)->field('title,id,is_up')->select();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-27 14:14
|
||||
* @功能说明:检测状态
|
||||
*/
|
||||
|
||||
|
||||
public function checkStatus($id,$status){
|
||||
|
||||
$info = $this->levelInfo(['id'=>$id]);
|
||||
|
||||
if(empty($info)){
|
||||
|
||||
return [ 'code' => 400,'msg' => '未找到' ];
|
||||
|
||||
}
|
||||
//开启
|
||||
if($status==1){
|
||||
|
||||
$dis[] = ['uniacid','=',$info['uniacid']];
|
||||
|
||||
$dis[] = ['status','=',0];
|
||||
|
||||
$dis[] = ['type','=',0];
|
||||
|
||||
$data = $this->where($dis)->order('top')->find();
|
||||
|
||||
if($data['id']!=$id){
|
||||
|
||||
return [ 'code' => 400,'msg' => '请先开启上级或下级'];
|
||||
|
||||
}
|
||||
}
|
||||
//关闭
|
||||
if($status==0){
|
||||
|
||||
$dis[] = ['uniacid','=',$info['uniacid']];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
$dis[] = ['type','=',0];
|
||||
|
||||
$data = $this->where($dis)->order('top desc')->find();
|
||||
|
||||
if($data['id'] != $id){
|
||||
|
||||
return [ 'code' => 400,'msg' => '请先关闭上级或下级'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return [ 'code' => 200,'msg' => '' ];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-28 11:23
|
||||
* @功能说明:获取等级
|
||||
*/
|
||||
|
||||
public function getMemberLevel($uniacid,$growth,$type = 0){
|
||||
|
||||
$where = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'status' => 1,
|
||||
|
||||
'type' => 0
|
||||
];
|
||||
|
||||
if($type==0){
|
||||
|
||||
$data = $this->where($where)->where('growth','>',$growth)->order('growth')->find();
|
||||
|
||||
}else{
|
||||
|
||||
$data = $this->where($where)->where('growth','<=',$growth)->order('growth desc')->find();
|
||||
|
||||
}
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-10 14:09
|
||||
* @功能说明:获取用户等级
|
||||
*/
|
||||
public function getUserLevelV2($user_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'b.id' => $user_id
|
||||
];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('massage_service_user_list b','a.id = b.member_level')
|
||||
->where($dis)
|
||||
->field('a.*')
|
||||
->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-18 10:14
|
||||
* @功能说明:获取plus会员
|
||||
*/
|
||||
public function getPlusLvel($uniacid){
|
||||
|
||||
|
||||
$where = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'status' => 1,
|
||||
|
||||
'type' => 1,
|
||||
|
||||
'top' => 999
|
||||
];
|
||||
|
||||
$data = $this->where($where)->order('growth')->find();
|
||||
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-30 09:45
|
||||
* @功能说明:获取用户的等级
|
||||
*/
|
||||
public function getUserLevel($uid,$uniacid){
|
||||
|
||||
$member_model = new Member();
|
||||
|
||||
$over_time = $member_model->where(['user_id'=>$uid])->value('over_time');
|
||||
//查看是否是plus会员 -1是永久有效
|
||||
if($over_time>time()||$over_time==-1){
|
||||
|
||||
$level = $this->getPlusLvel($uniacid);
|
||||
|
||||
if(!empty($level)){
|
||||
|
||||
return $level;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$growth = $member_model->where(['user_id'=>$uid])->value('growth');
|
||||
|
||||
$growth = !empty($growth)?$growth:0;
|
||||
|
||||
$level = $this->getMemberLevel($uniacid,$growth,1);
|
||||
|
||||
|
||||
return $level;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-07 09:39
|
||||
* @功能说明:
|
||||
*/
|
||||
public function getAllLevel($uniacid){
|
||||
|
||||
$where = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'status' => 1,
|
||||
|
||||
// 'type' => 0
|
||||
];
|
||||
|
||||
$son_level = $this->where($where)->column('id');
|
||||
|
||||
return $son_level;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-30 09:53
|
||||
* @功能说明:获取下级或者上级的等级
|
||||
*/
|
||||
public function getSonLevel($level,$uniacid,$type=0){
|
||||
|
||||
$where = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'status' => 1,
|
||||
|
||||
];
|
||||
|
||||
if($type==0){
|
||||
|
||||
$son_level = $this->where($where)->where('top','<',$level['top'])->column('id');
|
||||
|
||||
}else{
|
||||
|
||||
$icon = $level['top']==999?'>=':'>';
|
||||
|
||||
$son_level = $this->where($where)->where('top',$icon,$level['top'])->column('id');
|
||||
|
||||
}
|
||||
|
||||
return $son_level;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-31 10:39
|
||||
* @功能说明:升级用户的权益
|
||||
*/
|
||||
public function upUserRights($level,$order){
|
||||
|
||||
$uniacid = $order['uniacid'];
|
||||
|
||||
$user_id = $order['user_id'];
|
||||
|
||||
$integral_model = new Integral();
|
||||
|
||||
$member_model = new Member();
|
||||
|
||||
$coupon_model = new Coupon();
|
||||
|
||||
$level_info = $this->levelInfo(['top'=>$level,'uniacid'=>$uniacid]);
|
||||
//增加积分记录
|
||||
$integral_model->integralUserAdd($user_id,$level_info['send_integral'],$uniacid);
|
||||
//加会员的积分
|
||||
$dis = [
|
||||
'user_id' => $user_id
|
||||
];
|
||||
|
||||
$member_model->incDecGrowth($dis,$level_info['send_integral'],'integral');
|
||||
//赠送优惠券
|
||||
$coupon_model->insertCoupon($level_info,$order);
|
||||
//第一次升级时候 修改创建时间
|
||||
$member_model->where(['user_id'=>$order['user_id'],'is_vip'=>0])->update(['create_time'=>time(),'is_vip'=>1]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-04 17:22
|
||||
* @功能说明:会员成长值
|
||||
*/
|
||||
public function memberGrowth($uniacid){
|
||||
|
||||
$data = $this->where(['uniacid'=>$uniacid,'status'=>1,'type'=>0])->min('growth');
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-18 17:02
|
||||
* @功能说明:
|
||||
*/
|
||||
public function upUserRightsEnd($update,$order){
|
||||
|
||||
$user_id = $order['user_id'];
|
||||
|
||||
$uniacid = $order['uniacid'];
|
||||
|
||||
$member_model = new Member();
|
||||
//还未升级以前的等级
|
||||
$level_start = $this->getUserLevel($user_id,$uniacid);
|
||||
//如果空就不是会员
|
||||
$level_start = !empty($level_start['top'])?$level_start['top']:0;
|
||||
//更新会员信息
|
||||
$member_model->where(['user_id'=>$user_id])->update($update);
|
||||
//增加后的等级
|
||||
$level_end = $this->getUserLevel($user_id,$uniacid);
|
||||
|
||||
$level_end = !empty($level_end['top'])?$level_end['top']:0;
|
||||
//普通会员升级礼包
|
||||
if($level_end>$level_start){
|
||||
|
||||
$this->upUserRights($level_end,$order);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
138
app/member/model/Log.php
Normal file
138
app/member/model/Log.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class Log extends BaseModel
|
||||
{
|
||||
//会员权益表
|
||||
protected $name = 'longbing_card_v2_syn_log';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-09 10:37
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function storedList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-08-27 17:16
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function updateSome($id,$coupon,$uniacid){
|
||||
|
||||
$coupon_model = new StoredCoupon();
|
||||
|
||||
$coupon_model->where(['stored_id'=>$id])->delete();
|
||||
|
||||
if(!empty($coupon)){
|
||||
|
||||
foreach ($coupon as $value){
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'coupon_id'=> $value['coupon_id'],
|
||||
|
||||
'stored_id'=> $id,
|
||||
|
||||
'num' => $value['num']
|
||||
|
||||
];
|
||||
|
||||
$coupon_model->insert($insert);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function storedInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:13
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function storedUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
if(isset($data['coupon'])){
|
||||
|
||||
$coupon = $data['coupon'];
|
||||
|
||||
unset($data['coupon']);
|
||||
}
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
if(!empty($coupon)){
|
||||
|
||||
$id = $dis['id'];
|
||||
|
||||
$this->updateSome($id,$coupon,$data['uniacid']);
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
624
app/member/model/Member.php
Normal file
624
app/member/model/Member.php
Normal file
@@ -0,0 +1,624 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\massage\model\CarAtvRecord;
|
||||
use app\massage\model\Order;
|
||||
use app\member\info\PermissionMember;
|
||||
use app\shop\model\AdminShopOrder;
|
||||
use think\facade\Db;
|
||||
|
||||
class Member extends BaseModel
|
||||
{
|
||||
|
||||
|
||||
//会员商品表 该表暂时不使用
|
||||
protected $name = 'longbing_card_v2_member_level';
|
||||
|
||||
|
||||
// protected $append = [
|
||||
//
|
||||
// 'level_content',
|
||||
//
|
||||
// 'level_top'
|
||||
//
|
||||
// ];
|
||||
|
||||
protected $resultSetType = 'collection';
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:获取等级名称
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-16 09:47
|
||||
*/
|
||||
public function getLevelContentAttr($value,$data){
|
||||
|
||||
if(!empty($data['user_id'])&&!empty($data['uniacid'])){
|
||||
|
||||
$level_model = new Level();
|
||||
|
||||
$text = $level_model->getUserLevel($data['user_id'],$data['uniacid']);
|
||||
|
||||
return !empty($text)?$text['title']:'';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:获取等级名称
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-16 09:47
|
||||
*/
|
||||
public function getLevelTopAttr($value,$data){
|
||||
|
||||
if(!empty($data['user_id'])&&!empty($data['uniacid'])){
|
||||
|
||||
$level_model = new Level();
|
||||
|
||||
$text = $level_model->getUserLevel($data['user_id'],$data['uniacid']);
|
||||
|
||||
return !empty($text)?$text['top']:'';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-11 11:36
|
||||
* @功能说明:
|
||||
*
|
||||
*/
|
||||
public function memberUpdateInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$this->memberAdd($dis);
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
}
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function memberAdd($data){
|
||||
|
||||
$data['status'] = 1;
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function memberInfo($dis){
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_user b','a.user_id = b.id','left')
|
||||
->where($dis)
|
||||
->field(['a.*','b.nickName','b.avatarUrl','ifnull(a.growth,0) as growth','ifnull(a.integral,0) as integral'])
|
||||
->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function memberInfoIndex($dis){
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_user b','a.user_id = b.id','right')
|
||||
->where($dis)
|
||||
->field(['ifnull(a.over_time,0) as over_time','a.id','b.nickName','b.avatarUrl','ifnull(a.stored,0) as balance','ifnull(a.cash_stored,0) as cash_balance','ifnull(a.over_time,0) as over_time','ifnull(a.growth,0) as growth','ifnull(a.integral,0) as integral'])
|
||||
->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-16 09:35
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function memberUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-19 13:50
|
||||
* @功能说明:会员列表
|
||||
*/
|
||||
public function memberListV2(){
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-16 09:41
|
||||
* @功能说明:会员列表
|
||||
*/
|
||||
|
||||
public function memberList($dis,$where,$mapor,$page){
|
||||
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_user b','a.user_id = b.id')
|
||||
->where($dis)
|
||||
->where(function ($query) use ($mapor){
|
||||
$query->whereOr($mapor);
|
||||
})
|
||||
->where(function ($query) use ($where){
|
||||
$query->whereOr($where);
|
||||
})
|
||||
->field(['a.*','b.nickName','b.id as user_id',])
|
||||
->group('a.id')
|
||||
->order(['a.create_time desc','a.id'])
|
||||
->paginate($page)
|
||||
->toArray();
|
||||
|
||||
$order_model = new AdminShopOrder();
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$v['member_phone'] = Db::name('longbing_card_user_phone')->where(['user_id'=>$v['user_id']])->value('phone');
|
||||
|
||||
$diss = [];
|
||||
|
||||
$diss[] = ['uniacid','=',$v['uniacid']];
|
||||
|
||||
$diss[] = ['user_id','=',$v['user_id']];
|
||||
|
||||
$diss[] = ['create_time','>',$v['create_time']];
|
||||
|
||||
$diss[] = ['pay_status','=',1];
|
||||
//消费金额
|
||||
$v['price'] = $order_model->where($diss)->sum('total_price');
|
||||
//订单量
|
||||
$v['order_num'] = $order_model->where($diss)->count();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-09-08 10:20
|
||||
* @功能说明:讲所有用户添加到会员表
|
||||
*/
|
||||
public function memberInit($uniacid){
|
||||
|
||||
$member_user = $this->where(['uniacid'=>$uniacid])->column('user_id');
|
||||
|
||||
$no_member_user = Db::name('longbing_card_user')->where(['uniacid'=>$uniacid])->where('id','not in',$member_user)->column('id');
|
||||
|
||||
if(!empty($no_member_user)){
|
||||
|
||||
foreach ($no_member_user as $value){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'user_id' => $value
|
||||
];
|
||||
|
||||
$this->getMemberInfo($dis);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-16 15:30
|
||||
* @功能说明:统计
|
||||
*/
|
||||
public function listForm($id){
|
||||
|
||||
$order_model = new \app\shop\model\Order();
|
||||
|
||||
$car_order_model = new Order();
|
||||
|
||||
$record_model = new CarAtvRecord();
|
||||
|
||||
$dis[] = ['user_id','=',$id];
|
||||
|
||||
$dis[] = ['pay_type','>',1];
|
||||
|
||||
// $dis[] = ['create_time','>',$member['create_time']];
|
||||
//商城消费金额
|
||||
$shop_price = $order_model->where($dis)->sum('true_price');
|
||||
//商城订单量
|
||||
$shop_count = $order_model->where($dis)->count();
|
||||
//赛车订单
|
||||
$car_price = $car_order_model->where($dis)->sum('pay_price');
|
||||
//赛车订单量
|
||||
$car_count = $car_order_model->where($dis)->count();
|
||||
//活动订单
|
||||
$atv_price = $record_model->where($dis)->sum('pay_price');
|
||||
//活动订单量
|
||||
$atv_count = $record_model->where($dis)->count();
|
||||
|
||||
$data = [
|
||||
|
||||
'price' => round($shop_price+$car_price+$atv_price,2),
|
||||
|
||||
'count' => round($shop_count+$car_count+$atv_count,2),
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-10-19 16:09
|
||||
* @功能说明:获取总的订单
|
||||
*/
|
||||
public function totalOrder($user_id,$type=1){
|
||||
|
||||
$order_model = new Order();
|
||||
|
||||
// $dis = [
|
||||
//
|
||||
// ''
|
||||
// ]
|
||||
|
||||
if($type==1){
|
||||
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-28 09:44
|
||||
* @功能说明:用户信息
|
||||
*/
|
||||
public function userInfo($user_id,$uniacid){
|
||||
|
||||
$dis = [
|
||||
|
||||
'b.id' => $user_id
|
||||
|
||||
];
|
||||
//用户信息
|
||||
$user_info = $this->memberInfoIndex($dis);
|
||||
//等级模型
|
||||
$level_model = new Level();
|
||||
|
||||
$user_info['now_level'] = $level_model->getUserLevel($user_id,$uniacid);
|
||||
//是否是会员
|
||||
$user_info['is_member'] = !empty($user_info['now_level'])?1:0;
|
||||
|
||||
if(!empty($user_info['now_level'])&&$user_info['now_level']['top']==999){
|
||||
//下一级等级
|
||||
$user_info['next_level'] = [];
|
||||
|
||||
}else{
|
||||
//下一级等级
|
||||
$user_info['next_level'] = $level_model->getMemberLevel($uniacid,$user_info['growth']);
|
||||
}
|
||||
|
||||
return $user_info;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-31 09:16
|
||||
* @功能说明:更新会员
|
||||
*/
|
||||
public function updateMember($order){
|
||||
|
||||
$growth_model = new Growth();
|
||||
|
||||
$level_model = new Level();
|
||||
|
||||
$integral_model = new Integral();
|
||||
|
||||
$member_goods_model = new Goods();
|
||||
|
||||
Db::startTrans();
|
||||
//还未升级以前的等级
|
||||
$level_start = $level_model->getUserLevel($order['user_id'],$order['uniacid']);
|
||||
//如果空就不是会员
|
||||
$level_start = !empty($level_start['top'])?$level_start['top']:0;
|
||||
//普通会员给成长值,plus会员给时间
|
||||
$member_goods_model->ordertypeUpdate($order);
|
||||
//增加成长值
|
||||
$growth_model->incUserGrowth($order['id'],$order['user_id'],$order['uniacid']);
|
||||
//增加后的等级
|
||||
$level_end = $level_model->getUserLevel($order['user_id'],$order['uniacid']);
|
||||
|
||||
$level_end = !empty($level_end['top'])?$level_end['top']:0;
|
||||
//普通会员升级礼包
|
||||
if($level_end>$level_start){
|
||||
|
||||
$level_model->upUserRights($level_end,$order);
|
||||
|
||||
}
|
||||
//增加积分
|
||||
$integral_model->incUserIntegral($order['id'],$order['user_id'],$order['uniacid']);
|
||||
|
||||
Db::commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-31 09:43
|
||||
* @功能说明:加减成长值
|
||||
*/
|
||||
public function incDecGrowth($dis,$growth,$file = 'growth',$type = 0){
|
||||
|
||||
if($type==0){
|
||||
|
||||
$this->where($dis)->update([$file=>Db::raw("$file+$growth")]);
|
||||
|
||||
}else{
|
||||
|
||||
$this->where($dis)->update([$file=>Db::raw("$file-$growth")]);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @功能说明:获取数据 没有就添加一条
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-31 09:27
|
||||
*/
|
||||
|
||||
public function getMemberInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$this->memberAdd($dis);
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
}
|
||||
|
||||
return $data->toArray();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-03 11:51
|
||||
* @功能说明:商品详情
|
||||
*/
|
||||
public function goodsInfoMember($goods_id,$user_id,$uniacid){
|
||||
|
||||
//会员权限
|
||||
$member_p = new PermissionMember($uniacid);
|
||||
//会员商品折扣模型
|
||||
$discount_goods_model = new DiscountGoods();
|
||||
//会员配置模型
|
||||
$member_config_model = new Config();
|
||||
//会员等级模型
|
||||
$level_model = new Level();
|
||||
|
||||
$member_config = $member_config_model->configInfo(['uniacid'=>$uniacid]);
|
||||
//sass端授权
|
||||
$member_auth = $member_p->pAuth();
|
||||
//会员开关
|
||||
$data['member_auth'] = $member_config['status']==1?$member_auth:false;
|
||||
//会员商品折扣
|
||||
$data['goods_discount'] = $discount_goods_model->userGoodsDiscount($goods_id,$user_id,$uniacid);
|
||||
|
||||
$data['goods_discount'] = $data['goods_discount']*10;
|
||||
//会员等级
|
||||
$level = $level_model->getUserLevel($user_id,$uniacid);
|
||||
|
||||
$data['level_title'] = !empty($level)?$level['title']:'';
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-04 09:30
|
||||
* @功能说明:会员购买的回调
|
||||
*/
|
||||
|
||||
public function memberPayResult($order){
|
||||
|
||||
$config_model = new Config();
|
||||
//配置
|
||||
$config = $config_model->configInfo(['uniacid'=>$order['uniacid']]);
|
||||
|
||||
if($config['status']==1){
|
||||
|
||||
$level_model = new Level();
|
||||
|
||||
$integral_model = new Integral();
|
||||
|
||||
$growth_model = new Growth();
|
||||
//配置
|
||||
$config = $config_model->configInfo(['uniacid'=>$order['uniacid']]);
|
||||
//等级
|
||||
$level = $level_model->getUserLevel($order['user_id'],$order['uniacid']);
|
||||
//每日限领积分
|
||||
$day_integral = $integral_model->dayIntegral($order['user_id'],$order['uniacid']);
|
||||
//赠送积分
|
||||
if(!empty($config['integral_cash'])){
|
||||
//积分
|
||||
$integral = $order['total_price']*$config['integral_cash'];
|
||||
//积分倍率
|
||||
$balance = !empty($level['integral_switch'])?$level['integral']:1;
|
||||
//要加的积分
|
||||
$integral = $integral*$balance;
|
||||
//最终的积分
|
||||
$integral = is_numeric($day_integral)&&$day_integral<$integral?$day_integral:$integral;
|
||||
//添加积分记录
|
||||
$integral_model->integralUserAdd($order['user_id'],$integral,$order['uniacid'],1,1,$order['id']);
|
||||
|
||||
}
|
||||
//每日限领成长值
|
||||
$day_growth = $growth_model->dayGrowth($order['user_id'],$order['uniacid']);
|
||||
//赠送增长值(金额)
|
||||
if(!empty($config['growth_cash'])&&!empty($level)){
|
||||
//成长值
|
||||
$growth_cash = intval($order['total_price']*$config['growth_cash']);
|
||||
//最终成长值
|
||||
$growth_cash = is_numeric($day_growth)&&$day_growth<$growth_cash?$day_growth:$growth_cash;
|
||||
//添加成长值记录
|
||||
$growth_model->addUserGrowth($order['uniacid'],$order['user_id'],$growth_cash,$order['id'],1);
|
||||
}
|
||||
//赠送增长值(订单) 只有会员才送
|
||||
if(!empty($config['growth_order'])&&!empty($level)){
|
||||
//成长值
|
||||
$growth_cash = intval($config['growth_order']);
|
||||
//最终成长值
|
||||
$growth_cash = is_numeric($day_growth)&&$day_growth<$growth_cash?$day_growth:$growth_cash;
|
||||
//添加成长值记录
|
||||
$growth_model->addUserGrowth($order['uniacid'],$order['user_id'],$growth_cash,$order['id'],1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-07 17:12
|
||||
* @功能说明:退款
|
||||
*/
|
||||
public function refundOrder($order_id){
|
||||
|
||||
$integral_model = new Integral();
|
||||
|
||||
$growth_model = new Growth();
|
||||
|
||||
$dis = [
|
||||
|
||||
'order_id' => $order_id
|
||||
];
|
||||
|
||||
$integral_model->where($dis)->update(['refund'=>1]);
|
||||
|
||||
$growth_model->where($dis)->update(['refund'=>1]);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-08-11 11:25
|
||||
* @功能说明:会员权限
|
||||
*/
|
||||
public function getAuth($uniacid){
|
||||
|
||||
$config_model = new Config();
|
||||
|
||||
$config = $config_model->configInfo(['uniacid'=>$uniacid]);
|
||||
|
||||
$persisson = new PermissionMember($uniacid);
|
||||
|
||||
$auth = $persisson->pAuth();
|
||||
|
||||
$auth = $config['status']==1?$auth:false;
|
||||
|
||||
return $auth;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
368
app/member/model/Rights.php
Normal file
368
app/member/model/Rights.php
Normal file
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\massage\model\CouponRecord;
|
||||
use think\facade\Db;
|
||||
|
||||
class Rights extends BaseModel
|
||||
{
|
||||
//会员权益表
|
||||
protected $name = 'longbing_card_v2_member_rights';
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'status_text'
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-16 11:51
|
||||
* @功能说明:状态
|
||||
*/
|
||||
public function getStatusTextAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$relation_model = new RightsRelation();
|
||||
|
||||
$info = $relation_model->where(['rights_id'=>$data['id']])->find();
|
||||
|
||||
return !empty($info)?1:0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function rightsAdd($data){
|
||||
|
||||
$data['status'] = 1;
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-16 11:57
|
||||
* @功能说明:初始化
|
||||
*/
|
||||
public function initData($uniacid){
|
||||
|
||||
$dis = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'type' => 0
|
||||
|
||||
];
|
||||
|
||||
$data = $this->rightsInfo($dis);
|
||||
|
||||
if(empty($data)){
|
||||
|
||||
$arr = [
|
||||
|
||||
[
|
||||
'title' => '消费折扣',
|
||||
|
||||
'show_title' => '优享会员价',
|
||||
|
||||
'type' => 0,
|
||||
|
||||
'content' => '',
|
||||
|
||||
'top' => 10,
|
||||
|
||||
'icon' => 'https://longbingcdn.xiaochengxucms.com/admin/car/discount.png',
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'use_type' => 1,
|
||||
|
||||
'status' => 1
|
||||
|
||||
],[
|
||||
'title' => '积分倍率',
|
||||
|
||||
'show_title' => '会员多积分',
|
||||
|
||||
'type' => 0,
|
||||
|
||||
'content' => '',
|
||||
|
||||
'top' => 10,
|
||||
|
||||
'icon' => 'https://longbingcdn.xiaochengxucms.com/admin/car/multiple.png',
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'use_type' => 2,
|
||||
|
||||
'status' => 1
|
||||
],[
|
||||
'title' => '赠送积分',
|
||||
|
||||
'show_title' => '会员专享积分',
|
||||
|
||||
'type' => 0,
|
||||
|
||||
'content' => '',
|
||||
|
||||
'top' => 10,
|
||||
|
||||
'icon' => 'https://longbingcdn.xiaochengxucms.com/admin/car/integral.png',
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'use_type' => 3,
|
||||
|
||||
'status' => 1,
|
||||
|
||||
'is_up' => 1
|
||||
|
||||
],
|
||||
[
|
||||
|
||||
'title' => '会员送券',
|
||||
|
||||
'show_title' => '送卡券',
|
||||
|
||||
'type' => 0,
|
||||
|
||||
'content' => '',
|
||||
|
||||
'top' => 10,
|
||||
|
||||
'icon' => 'https://longbingcdn.xiaochengxucms.com/admin/car/coupon.png',
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'use_type' => 4,
|
||||
|
||||
'status' => 1,
|
||||
|
||||
'is_up' => 1
|
||||
]
|
||||
];
|
||||
|
||||
$this->saveAll($arr);
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:12
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function rightsList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function rightsInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:13
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function rightsUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-22 16:58
|
||||
* @功能说明:自定义权益
|
||||
*/
|
||||
public function customRights($member_id){
|
||||
|
||||
$dis[]= ['b.member_id','=',$member_id];
|
||||
|
||||
$dis[]= ['b.type','=',1];
|
||||
|
||||
$dis[]= ['a.status','=',1];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_v2_member_rights_relation b','a.id = b.rights_id')
|
||||
->where($dis)
|
||||
->group('b.rights_id')
|
||||
->column('a.title');
|
||||
|
||||
return array_values($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-28 10:38
|
||||
* @功能说明:会员权益
|
||||
*/
|
||||
public function memberRights($level_id,$uniacid){
|
||||
|
||||
$dis = [
|
||||
|
||||
'b.member_id' => $level_id,
|
||||
|
||||
'b.uniacid' => $uniacid,
|
||||
|
||||
'a.status' => 1
|
||||
];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_v2_member_rights_relation b','a.id = b.rights_id')
|
||||
->where($dis)
|
||||
->field(['a.id','a.show_title','a.type','a.use_type','a.icon'])
|
||||
->group('a.id')
|
||||
->order(['a.top desc','a.id desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-29 10:49
|
||||
* @功能说明:商品等级下拉框
|
||||
*/
|
||||
public function goodsLevelSelect($dis){
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_member_rights_relation b','a.id = b.rights_id')
|
||||
->join('longbing_card_member_level c','c.id = b.member_id')
|
||||
->where($dis)
|
||||
->field('c.title,c.id,c.top')
|
||||
->group('c.id')
|
||||
->order('c.top')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-11-12 17:40
|
||||
* @功能说明:给用户权益
|
||||
*/
|
||||
public function giveRights($level_id,$user_id,$order_id=0){
|
||||
|
||||
$log_model = new RightsLog();
|
||||
|
||||
$level_model = new Level();
|
||||
|
||||
$level = $level_model->levelInfo(['id'=>$level_id]);
|
||||
|
||||
if(empty($level)){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$dis = [
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'level_id'=> $level_id,
|
||||
|
||||
'uniacid' => $level['uniacid']
|
||||
];
|
||||
//已经给或该权益了
|
||||
$find = $log_model->rightsInfo($dis);
|
||||
|
||||
if(!empty($find)){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$log_model->insert($dis);
|
||||
//赠送积分
|
||||
if(!empty($level['send_integral'])&&!empty($level['send_integral_switch'])){
|
||||
|
||||
$point_model = new Integral();
|
||||
|
||||
$point_model->integralUserAdd($user_id,$level['send_integral'],$level['uniacid'],2,0,$order_id);
|
||||
}
|
||||
//赠送卡券
|
||||
//优惠券
|
||||
$coupon_model= new Coupon();
|
||||
|
||||
$coupon_record_model = new CouponRecord();
|
||||
|
||||
$dis = [
|
||||
|
||||
'member_id' => $level_id
|
||||
];
|
||||
//优惠券
|
||||
$coupon = $coupon_model->where($dis)->select()->toArray();
|
||||
|
||||
if(!empty($coupon)&&!empty($level['coupon_switch'])){
|
||||
|
||||
foreach ($coupon as &$value){
|
||||
|
||||
$coupon_record_model->recordAdd($value['coupon_id'],$user_id,$value['num']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
79
app/member/model/RightsLog.php
Normal file
79
app/member/model/RightsLog.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class RightsLog extends BaseModel
|
||||
{
|
||||
//会员权益表
|
||||
protected $name = 'longbing_card_v2_member_rights_log';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function rightsAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:12
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function rightsList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function rightsInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:13
|
||||
* @功能说明:删除直播
|
||||
*/
|
||||
public function rightsUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
79
app/member/model/RightsRelation.php
Normal file
79
app/member/model/RightsRelation.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class RightsRelation extends BaseModel
|
||||
{
|
||||
//会员权益表
|
||||
protected $name = 'longbing_card_v2_member_rights_relation';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function rightsAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:12
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function rightsList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function rightsInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:13
|
||||
* @功能说明:删除直播
|
||||
*/
|
||||
public function rightsUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
177
app/member/model/Stored.php
Normal file
177
app/member/model/Stored.php
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class Stored extends BaseModel
|
||||
{
|
||||
//会员权益表
|
||||
protected $name = 'longbing_card_member_stored';
|
||||
|
||||
protected $append = [
|
||||
|
||||
'stored_type'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-11 11:07
|
||||
* @功能说明:储值卡的类型
|
||||
*/
|
||||
public function getStoredTypeAttr($value,$data){
|
||||
|
||||
if(!empty($data['id'])){
|
||||
|
||||
$stored_level_model = new StoredLevel();
|
||||
|
||||
$type = $stored_level_model->storedType($data['id']);
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-09 10:37
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function storedList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function storedAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$data['status'] = 1;
|
||||
|
||||
if(isset($data['coupon'])){
|
||||
|
||||
$coupon = $data['coupon'];
|
||||
|
||||
unset($data['coupon']);
|
||||
}
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
if(!empty($coupon)){
|
||||
|
||||
$id = $this->getLastInsID();
|
||||
|
||||
$this->updateSome($id,$coupon,$data['uniacid']);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-08-27 17:16
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function updateSome($id,$coupon,$uniacid){
|
||||
|
||||
$coupon_model = new StoredCoupon();
|
||||
|
||||
$coupon_model->where(['stored_id'=>$id])->delete();
|
||||
|
||||
if(!empty($coupon)){
|
||||
|
||||
foreach ($coupon as $value){
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'coupon_id'=> $value['coupon_id'],
|
||||
|
||||
'stored_id'=> $id,
|
||||
|
||||
'num' => $value['num']
|
||||
|
||||
];
|
||||
|
||||
$coupon_model->insert($insert);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function storedInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:13
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function storedUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
if(isset($data['coupon'])){
|
||||
|
||||
$coupon = $data['coupon'];
|
||||
|
||||
unset($data['coupon']);
|
||||
}
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
if(!empty($coupon)){
|
||||
|
||||
$id = $dis['id'];
|
||||
|
||||
$this->updateSome($id,$coupon,$data['uniacid']);
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
156
app/member/model/StoredCoupon.php
Normal file
156
app/member/model/StoredCoupon.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\shop\model\IndexCouponRecord;
|
||||
use think\facade\Db;
|
||||
|
||||
class StoredCoupon extends BaseModel
|
||||
{
|
||||
//会员权益表
|
||||
protected $name = 'longbing_card_erp_stored_coupon';
|
||||
|
||||
protected $append = [
|
||||
|
||||
'stored_type'
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-09 10:37
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function storedList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-15 09:49
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function storedAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$data['status'] = 1;
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:08
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function storedInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-04-26 17:13
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function storedUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-08 16:30
|
||||
* @功能说明:添加用户的优惠券
|
||||
*/
|
||||
public function insertCoupon($id,$user_id,$uniacid){
|
||||
|
||||
|
||||
$order = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'to_uid' => 0
|
||||
];
|
||||
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.stored_id' => $id
|
||||
];
|
||||
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_coupon b','a.coupon_id = b.id')
|
||||
->where($dis)
|
||||
->group('a.coupon_id')
|
||||
->field('b.*,a.num as coupon_num')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$record_model = new IndexCouponRecord();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $coupon){
|
||||
|
||||
for ($i=0;$i<$coupon['coupon_num'];$i++){
|
||||
|
||||
if(!isset($order['staff_id'])&&isset($order['to_uid'])){
|
||||
|
||||
$order['staff_id'] = $order['to_uid'];
|
||||
}
|
||||
//领取优惠券
|
||||
$record_model->insertRecord($coupon,$order);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
101
app/member/model/StoredLevel.php
Normal file
101
app/member/model/StoredLevel.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class StoredLevel extends BaseModel
|
||||
{
|
||||
//会员权益表
|
||||
protected $name = 'longbing_card_member_level_stored';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-07 16:18
|
||||
* @功能说明:添加优惠券
|
||||
*/
|
||||
public function addStored($stored, $level_id,$data){
|
||||
|
||||
$this->where(['member_id'=>$level_id])->delete();
|
||||
|
||||
if(!empty($stored)){
|
||||
|
||||
array_walk($stored, function ($value, $key) use (&$stored, $level_id,$data) {
|
||||
|
||||
$stored[$key] = [
|
||||
//等级id
|
||||
'member_id' => $level_id,
|
||||
|
||||
'uniacid' => $data['uniacid'],
|
||||
|
||||
'stored_id' => $value,
|
||||
|
||||
];
|
||||
|
||||
});
|
||||
//添加
|
||||
$res = $this->saveAll($stored);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-11 11:10
|
||||
* @功能说明:储值卡类型
|
||||
*/
|
||||
public function storedType($stored_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.stored_id' => $stored_id,
|
||||
|
||||
'b.status' => 1,
|
||||
|
||||
'b.type' => 1
|
||||
];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_member_level b','a.member_id=b.id')
|
||||
->where($dis)
|
||||
->find();
|
||||
|
||||
return !empty($data)?1:0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-11 15:49
|
||||
* @功能说明:获取puls会员的详情
|
||||
*/
|
||||
public function getLevel($stored_id){
|
||||
|
||||
$dis = [
|
||||
|
||||
'a.stored_id' => $stored_id,
|
||||
|
||||
'b.status' => 1,
|
||||
|
||||
'b.type' => 1
|
||||
];
|
||||
|
||||
$data = $this->alias('a')
|
||||
->join('longbing_card_member_level b','a.member_id=b.id')
|
||||
->where($dis)
|
||||
->field('b.*')
|
||||
->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
566
app/member/model/StoredOrder.php
Normal file
566
app/member/model/StoredOrder.php
Normal file
@@ -0,0 +1,566 @@
|
||||
<?php
|
||||
namespace app\member\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use app\overlord\model\Active;
|
||||
use app\shop\controller\IndexPayResunt;
|
||||
use app\shop\model\IndexShopOrder;
|
||||
use think\facade\Db;
|
||||
|
||||
class StoredOrder extends BaseModel
|
||||
{
|
||||
//会员权益表
|
||||
protected $name = 'longbing_card_member_stored_order';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-17 17:47
|
||||
* @功能说明:订单详情
|
||||
*/
|
||||
public function orderInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-11 10:29
|
||||
* @功能说明:下单
|
||||
*/
|
||||
public function addOrder($stored,$user_id,$staff_id,$share_id){
|
||||
|
||||
$member_model = new Member();
|
||||
|
||||
$member_info = $member_model->getMemberInfo(['user_id'=>$user_id,'uniacid'=>$stored['uniacid']]);
|
||||
|
||||
$data = [
|
||||
|
||||
'create_time' => time(),
|
||||
|
||||
'status' => 0,
|
||||
|
||||
'user_id' => $user_id,
|
||||
|
||||
'staff_id' => $staff_id,
|
||||
|
||||
'stored_id' => $stored['id'],
|
||||
|
||||
'pay_price' => round($stored['pay_price'],2),
|
||||
|
||||
'true_price' => round($stored['true_price'],2),
|
||||
|
||||
'true_price_before' => round($member_info['stored'],2),
|
||||
|
||||
'true_price_after' => round($member_info['stored']+$stored['true_price'],2),
|
||||
|
||||
'growth' => $stored['growth'],
|
||||
|
||||
'title' => $stored['title'],
|
||||
|
||||
'uniacid' => $stored['uniacid'],
|
||||
|
||||
'order_code' => orderCode(),
|
||||
|
||||
'type' => $stored['stored_type'],
|
||||
|
||||
'over_time' => 0,
|
||||
|
||||
'share_id' => $share_id
|
||||
|
||||
];
|
||||
//如果是puls会员的,要把过期时间加好
|
||||
if($stored['stored_type']==1){
|
||||
|
||||
$stored_level_model = new StoredLevel();
|
||||
|
||||
$level = $stored_level_model->getLevel($stored['id']);
|
||||
|
||||
if(empty($level)){
|
||||
|
||||
return ['code'=>400,'msg'=>'等级未找到'];
|
||||
}
|
||||
|
||||
$data['over_time'] = $level['over_time'];
|
||||
}
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-17 13:48
|
||||
* @功能说明:订单退款时候处理储值
|
||||
*/
|
||||
public function orderRefundStore($order_id,$app,$refund_prices){
|
||||
|
||||
$order_model = new IndexShopOrder();
|
||||
|
||||
$order_info = $order_model->orderInfo(['id'=>$order_id]);
|
||||
//储值支付
|
||||
$reslut = new IndexPayResunt($app);
|
||||
//储值记录
|
||||
$res = $reslut->orderStoredResult($order_info,5,$refund_prices);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-16 10:52
|
||||
* @功能说明:储值扣款
|
||||
*/
|
||||
public function desStore($price,$text,$member_info,$controller_type,$controller,$order_code=0,$title=0){
|
||||
//注意:(3和5的order_code都是商城订单的order_code,其他的都是系统生成的)
|
||||
$order_code = !empty($order_code)?$order_code:orderCode();
|
||||
//4 是直接修改价格 1、2、3的是扣除 0、5充值是加,6是加 霸王餐优惠;7申请提现;8申请拒绝
|
||||
switch ($controller_type){
|
||||
|
||||
case 0:
|
||||
$true_price_after = round($member_info['stored']+$price,2);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$true_price_after = round($member_info['stored']-$price,2);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$true_price_after = round($member_info['stored']-$price,2);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$true_price_after = round($member_info['stored']-$price,2);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$true_price_after = $price;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$true_price_after = round($member_info['stored']+$price,2);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
$true_price_after = round($member_info['stored']+$price,2);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
$true_price_after = round($member_info['stored']-$price,2);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
$true_price_after = round($member_info['stored']+$price,2);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
$data = [
|
||||
|
||||
'create_time' => time(),
|
||||
|
||||
'pay_time' => time(),
|
||||
|
||||
'status' => 0,
|
||||
|
||||
'user_id' => $member_info['user_id'],
|
||||
|
||||
'staff_id' => in_array($controller_type,[1,4,6,7,8])?0:$controller,
|
||||
|
||||
'stored_id' => 0,
|
||||
|
||||
'pay_price' => round($price,2),
|
||||
|
||||
'true_price' => round($price,2),
|
||||
|
||||
'true_price_before' => round($member_info['stored'],2),
|
||||
//4 是直接修改价格 2、3的是扣除 1充值是加
|
||||
'true_price_after' => $true_price_after,
|
||||
|
||||
'growth' => 0,
|
||||
|
||||
'title' => $title,
|
||||
|
||||
'uniacid' => $member_info['uniacid'],
|
||||
|
||||
'order_code' => $order_code,
|
||||
|
||||
'type' => 0,
|
||||
|
||||
'over_time' => 0,
|
||||
|
||||
'share_id' => 0,
|
||||
|
||||
'status' => 2,
|
||||
|
||||
'controller_type' => $controller_type,
|
||||
|
||||
'controller' => $controller,
|
||||
|
||||
'text' => $text
|
||||
|
||||
];
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
$id = $this->getLastInsID();
|
||||
|
||||
if($res==1){
|
||||
|
||||
$member_model = new Member();
|
||||
|
||||
if(in_array($controller_type,[4])){
|
||||
|
||||
$y_price = $price;
|
||||
|
||||
}elseif (in_array($controller_type,[1,2,3])){
|
||||
|
||||
$y_price = $member_info['stored']-$price;
|
||||
|
||||
}elseif (in_array($controller_type,[0,5])){
|
||||
|
||||
$y_price = $member_info['stored']+$price;
|
||||
//霸王餐 优惠 管理员
|
||||
}elseif (in_array($controller_type,[6,8])){
|
||||
|
||||
$y_price = $member_info['stored']+$price;
|
||||
|
||||
$member_info['cash_stored'] +=$price;
|
||||
//提现 (霸王餐)
|
||||
}elseif (in_array($controller_type,[7])){
|
||||
|
||||
$y_price = $member_info['stored']-$price;
|
||||
|
||||
$member_info['cash_stored'] -=$price;
|
||||
|
||||
}
|
||||
|
||||
$where[] = ['id','=',$member_info['id']];
|
||||
|
||||
$where[] = ['stored','>=',0];
|
||||
|
||||
$res = $member_model->where($where)->update(['stored'=>$y_price,'cash_stored'=>$member_info['cash_stored']]);
|
||||
//目前只有员工扣款和后台扣款有佣金
|
||||
if(in_array($controller_type,[1,2])){
|
||||
|
||||
$order = $this->orderInfo(['id'=>$id]);
|
||||
//配置模型
|
||||
$congfig = new Config();
|
||||
//返佣
|
||||
$congfig->controllerCommission($order);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-11 10:59
|
||||
* @功能说明:回调
|
||||
*/
|
||||
public function orderResult($order_code,$transaction_id){
|
||||
|
||||
$order = $this->where(['order_code'=>$order_code])->find();
|
||||
|
||||
if(empty($order_code)||$order->status!=0){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$order = $order->toArray();
|
||||
//修改订单状态
|
||||
$this->where(['order_code'=>$order_code])->update(['status'=>2,'pay_time'=>time(),'transaction_id'=>$transaction_id]);
|
||||
//会员模型
|
||||
$member_model = new Member();
|
||||
//等级模型
|
||||
$level_model = new Level();
|
||||
//获取用户会员信息(没有则创建)
|
||||
$user_info = $member_model->memberUpdateInfo(['user_id'=>$order['user_id'],'uniacid'=>$order['uniacid']]);
|
||||
//送储值
|
||||
$row['stored'] = $user_info['stored']+$order['true_price'];
|
||||
//0是普通会员,要送成长值
|
||||
if($order['type']==0){
|
||||
|
||||
$row['growth'] = $user_info['growth']+$order['growth'];
|
||||
|
||||
$growth_model = new Growth();
|
||||
|
||||
$growth_model->addUserGrowth($order['uniacid'],$order['user_id'],$order['growth'],$order['id'],2,2);
|
||||
|
||||
|
||||
}else{
|
||||
//1是plus会员,给会员过期时间
|
||||
if($user_info['over_time']<time()){
|
||||
|
||||
$time = strtotime("+".$order['over_time']."month");
|
||||
|
||||
$row['over_time'] = $time;
|
||||
//赠送升级礼包
|
||||
//$level_model->upUserRights('999',$order);
|
||||
}
|
||||
}
|
||||
//编辑用户
|
||||
$level_model->upUserRightsEnd($row,$order);
|
||||
//返佣
|
||||
$config_model = new Config();
|
||||
|
||||
$config_model->storeOrderCommission($order);
|
||||
|
||||
$store_coupon = new StoredCoupon();
|
||||
|
||||
$store_coupon->insertCoupon($order['stored_id'],$order['user_id'],$order['uniacid']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-07-16 16:35
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function recordList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order(['create_time desc','id desc'])->paginate($page)->toArray();
|
||||
|
||||
if(!empty($data['data'])){
|
||||
|
||||
foreach ($data['data'] as &$v){
|
||||
|
||||
$v = $this->orderText($v['id']);
|
||||
|
||||
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-27 14:33
|
||||
* @功能说明:拼接扣款文案
|
||||
*/
|
||||
public function orderText($order_id){
|
||||
|
||||
$v = $this->orderInfo(['id'=>$order_id]);
|
||||
|
||||
//购买储值套餐
|
||||
if($v['controller_type']==0){
|
||||
|
||||
$v['controller_avatar'] = lbUserAvatar($v['user_id']);
|
||||
|
||||
$v['controller_name'] = '系统核算';
|
||||
|
||||
$icon = $v['true_price']>0?'+':'-';
|
||||
|
||||
$growth_add = $v['true_price']>0?$v['true_price']:$v['true_price']*-1;
|
||||
|
||||
$boj = $this->returnObj($v['type']);
|
||||
|
||||
$v['admin_text'] = $boj.'【'.$v['title'].'】'.$icon.'¥'.$growth_add.',现余额 ¥'.$v['true_price_after'];
|
||||
|
||||
$v['index_text'] = $boj.'【'.$v['title'].'】';
|
||||
|
||||
}elseif($v['controller_type']==1){
|
||||
//后台扣款
|
||||
$v['controller_name'] = Db::name('longbing_admin')->where(['admin_id'=>$v['controller']])->value('account');
|
||||
|
||||
$v['controller_avatar'] = 'https://retail.xiaochengxucms.com/defaultAvatar.png';
|
||||
|
||||
$v['admin_text'] = '扣除储值 ¥'.$v['true_price'].',现储值 ¥'.$v['true_price_after'];
|
||||
|
||||
$v['true_price'] = '-'.$v['true_price'];
|
||||
|
||||
$v['index_text'] = '系统扣除储值';
|
||||
|
||||
}elseif($v['controller_type']==2){
|
||||
//员工扣款
|
||||
$v['controller_avatar'] = lbUserAvatar($v['controller']);
|
||||
|
||||
$v['controller_name'] = lbUserName($v['controller']);
|
||||
|
||||
$v['admin_text'] = '扣除储值 ¥'.$v['true_price'].',现储值 ¥'.$v['true_price_after'];
|
||||
|
||||
$v['true_price'] = '-'.$v['true_price'];
|
||||
|
||||
$v['index_text'] = '员工扣除储值'.'【'.$v['controller_name'].'】';
|
||||
|
||||
}elseif ($v['controller_type']==3){
|
||||
//购买套餐
|
||||
$v['controller_avatar'] = lbUserAvatar($v['user_id']);
|
||||
|
||||
$v['controller_name'] = '系统核算';
|
||||
|
||||
$growth_add = $v['true_price']>0?$v['true_price']:$v['true_price']*-1;
|
||||
|
||||
$boj = $this->returnObj($v['controller_type']);
|
||||
|
||||
$v['admin_text'] = $boj.'【'.$v['title'].'】-¥'.$growth_add.',现余额 ¥'.$v['true_price_after'];
|
||||
|
||||
$v['index_text'] = $boj.'【'.$v['title'].'】';
|
||||
|
||||
$v['true_price'] = '-'.$v['true_price'];
|
||||
|
||||
}elseif ($v['controller_type']==4){
|
||||
//员工修改
|
||||
$v['controller_name'] = Db::name('longbing_admin')->where(['admin_id'=>$v['controller']])->value('account');
|
||||
|
||||
$v['controller_avatar'] = 'https://retail.xiaochengxucms.com/defaultAvatar.png';
|
||||
|
||||
$v['admin_text'] = '储值 ¥'.$v['true_price_before'].',修改为 ¥'.$v['true_price_after'];
|
||||
|
||||
$v['index_text'] = '系统修改储值';
|
||||
|
||||
}elseif ($v['controller_type']==5){
|
||||
//购买商品退款
|
||||
$v['controller_avatar'] = lbUserAvatar($v['user_id']);
|
||||
|
||||
$v['controller_name'] = '系统核算';
|
||||
|
||||
$growth_add = $v['true_price']>0?$v['true_price']:$v['true_price']*-1;
|
||||
|
||||
$boj = $this->returnObj($v['controller_type']);
|
||||
|
||||
$v['admin_text'] = $boj.'【'.$v['title'].'】+¥'.$growth_add.',现余额 ¥'.$v['true_price_after'];
|
||||
|
||||
$v['index_text'] = $boj.'【'.$v['title'].'】';
|
||||
|
||||
|
||||
}elseif ($v['controller_type']==6){
|
||||
//霸王餐优惠
|
||||
$v['controller_avatar'] = lbUserAvatar($v['user_id']);
|
||||
|
||||
$v['controller_name'] = is_numeric($v['controller'])?lbUserName($v['controller']):Db::name('longbing_admin')->where(['admin_id'=>$v['controller']])->value('account');;
|
||||
|
||||
$growth_add = $v['true_price'];
|
||||
|
||||
$boj = $this->returnObj($v['controller_type']);
|
||||
|
||||
$atv_model = new Active();
|
||||
|
||||
$title = $atv_model->where(['id'=>$v['title']])->value('title');
|
||||
|
||||
$v['admin_text'] = $boj.'【'.$title.'】'.'¥'.$growth_add.',现余额 ¥'.$v['true_price_after'];
|
||||
|
||||
$v['index_text'] = $boj.'【'.$title.'】';
|
||||
|
||||
}elseif ($v['controller_type']==7){
|
||||
//霸王餐优惠(提现)
|
||||
$v['controller_avatar'] = lbUserAvatar($v['user_id']);
|
||||
|
||||
$v['controller_name'] = is_numeric($v['controller'])?lbUserName($v['controller']):Db::name('longbing_admin')->where(['admin_id'=>$v['controller']])->value('account');;
|
||||
|
||||
$growth_add = $v['true_price'];
|
||||
|
||||
$boj = $this->returnObj($v['controller_type']);
|
||||
|
||||
$v['admin_text'] = $boj.'-¥'.$growth_add.',现余额 ¥'.$v['true_price_after'];
|
||||
|
||||
$v['true_price'] = '-'.$v['true_price'];
|
||||
|
||||
$v['index_text'] = $boj;
|
||||
|
||||
}elseif ($v['controller_type']==8){
|
||||
//霸王餐优惠(拒绝提现)
|
||||
$v['controller_avatar'] = lbUserAvatar($v['user_id']);
|
||||
|
||||
$v['controller_name'] = Db::name('longbing_admin')->where(['admin_id'=>$v['controller']])->value('account');;
|
||||
|
||||
$growth_add = $v['true_price'];
|
||||
|
||||
$boj = $this->returnObj($v['controller_type']);
|
||||
|
||||
$v['admin_text'] = $boj.'¥'.$growth_add.',现余额 ¥'.$v['true_price_after'];
|
||||
|
||||
$v['index_text'] = $boj;
|
||||
|
||||
}
|
||||
|
||||
return $v;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-14 15:17
|
||||
* @功能说明:返回一个对象
|
||||
*/
|
||||
public function returnObj($type){
|
||||
|
||||
switch ($type){
|
||||
//购买会员商品
|
||||
case 0:
|
||||
return '购买套餐';
|
||||
|
||||
break;
|
||||
//会员购买商品
|
||||
case 1:
|
||||
return '购买套餐';
|
||||
|
||||
break;
|
||||
//购买储值套餐赠送
|
||||
case 2:
|
||||
return '购买储值套餐赠送';
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
return '购买商品';
|
||||
|
||||
break;
|
||||
|
||||
case 5:
|
||||
return '商品退款';
|
||||
|
||||
break;
|
||||
case 6:
|
||||
return '霸王餐活动';
|
||||
|
||||
break;
|
||||
case 7:
|
||||
return '提现申请';
|
||||
|
||||
break;
|
||||
case 8:
|
||||
return '拒绝提现';
|
||||
|
||||
break;
|
||||
default:
|
||||
return '消费获得';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
130
app/member/route/route.php
Normal file
130
app/member/route/route.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
use think\facade\Route;
|
||||
|
||||
|
||||
Route::group('admin', function () {
|
||||
//权益列表
|
||||
Route::any('AdminRights/rightsList', 'AdminRights/rightsList');
|
||||
//添加权益
|
||||
Route::any('AdminRights/rightsAdd', 'AdminRights/rightsAdd');
|
||||
//权益详情
|
||||
Route::any('AdminRights/rightsInfo', 'AdminRights/rightsInfo');
|
||||
//权益编辑
|
||||
Route::any('AdminRights/rightsUpdate', 'AdminRights/rightsUpdate');
|
||||
//配置详情
|
||||
Route::any('AdminConfig/configInfo', 'AdminConfig/configInfo');
|
||||
//配置编辑
|
||||
Route::any('AdminConfig/configUpdate', 'AdminConfig/configUpdate');
|
||||
|
||||
Route::any('AdminConfig/commissionSelect', 'AdminConfig/commissionSelect');
|
||||
//等级列表
|
||||
Route::any('AdminLevel/levelList', 'AdminLevel/levelList');
|
||||
//会员等级下拉框
|
||||
Route::get('AdminLevel/levelSelectV2', 'AdminLevel/levelSelectV2');
|
||||
//等级详情
|
||||
Route::any('AdminLevel/levelInfo', 'AdminLevel/levelInfo');
|
||||
//等级编辑
|
||||
Route::any('AdminLevel/levelUpdate', 'AdminLevel/levelUpdate');
|
||||
//同步银豹会员等级
|
||||
Route::get('AdminLevel/synLevel', 'AdminLevel/synLevel');
|
||||
//会员商品
|
||||
Route::any('AdminLevel/memberGoods', 'AdminLevel/memberGoods');
|
||||
//上下架
|
||||
Route::any('AdminLevel/statusUpdate', 'AdminLevel/statusUpdate');
|
||||
//等级下拉框
|
||||
Route::any('AdminLevel/levelSelect', 'AdminLevel/levelSelect');
|
||||
//优惠券下拉框
|
||||
Route::any('AdminLevel/memberCouponSelect', 'AdminLevel/memberCouponSelect');
|
||||
//会员权限
|
||||
Route::any('AdminMember/memberAuth', 'AdminMember/memberAuth');
|
||||
//会员列表
|
||||
Route::any('AdminMember/memberList', 'AdminMember/memberList');
|
||||
//会员详情
|
||||
Route::any('AdminMember/memberInfo', 'AdminMember/memberInfo');
|
||||
|
||||
Route::any('AdminMember/waterList', 'AdminMember/waterList');
|
||||
//会员上下架
|
||||
Route::any('AdminMember/statusUpdate', 'AdminMember/statusUpdate');
|
||||
//修改成长值
|
||||
Route::any('AdminMember/updateGrowth', 'AdminMember/updateGrowth');
|
||||
|
||||
Route::get('AdminMember/memberListExcel', 'AdminMember/memberListExcel');
|
||||
//会员等级下拉框
|
||||
Route::any('AdminLevel/memberLevelSelect', 'AdminLevel/memberLevelSelect');
|
||||
//储值列表
|
||||
Route::any('AdminStored/storedList', 'AdminStored/storedList');
|
||||
//储值添加
|
||||
Route::any('AdminStored/storedAdd', 'AdminStored/storedAdd');
|
||||
//储值详情
|
||||
Route::any('AdminStored/storedInfo', 'AdminStored/storedInfo');
|
||||
//储值编辑
|
||||
Route::any('AdminStored/storedUpdate', 'AdminStored/storedUpdate');
|
||||
//储值下拉框
|
||||
Route::any('AdminStored/storedSelect', 'AdminStored/storedSelect');
|
||||
//后台扣款
|
||||
Route::any('AdminStored/staffDeduction', 'AdminStored/staffDeduction');
|
||||
//同意提现
|
||||
Route::any('AdminStored/cashPass', 'AdminStored/cashPass');
|
||||
//拒绝提现
|
||||
Route::any('AdminStored/cashNoPass', 'AdminStored/cashNoPass');
|
||||
//提现记录
|
||||
Route::any('AdminStored/userCashList', 'AdminStored/userCashList');
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
Route::group('app', function () {
|
||||
//会员详情
|
||||
Route::any('IndexMember/memberInfo', 'IndexMember/memberInfo');
|
||||
//等级详情
|
||||
Route::any('IndexMember/levelInfo', 'IndexMember/levelInfo');
|
||||
//等级列表
|
||||
Route::any('IndexMember/levelList', 'IndexMember/levelList');
|
||||
//权益详情
|
||||
Route::any('IndexMember/rightsInfo', 'IndexMember/rightsInfo');
|
||||
//会员配置
|
||||
Route::any('IndexMember/memberConfig', 'IndexMember/memberConfig');
|
||||
|
||||
Route::any('IndexMember/userMember', 'IndexMember/userMember');
|
||||
//储值套餐列表
|
||||
Route::any('IndexStored/storedList', 'IndexStored/storedList');
|
||||
//储值下单
|
||||
Route::any('IndexStored/payOrder', 'IndexStored/payOrder');
|
||||
|
||||
Route::any('IndexStored/storedInfo', 'IndexStored/storedInfo');
|
||||
|
||||
Route::any('IndexStored/storedMemberInfo', 'IndexStored/storedMemberInfo');
|
||||
|
||||
Route::any('IndexStored/shareCouponInfo', 'IndexStored/shareCouponInfo');
|
||||
//员工扣款
|
||||
Route::any('IndexStored/staffDeduction', 'IndexStored/staffDeduction');
|
||||
|
||||
Route::any('IndexStored/orderList', 'IndexStored/orderList');
|
||||
|
||||
Route::any('IndexStored/applyTx', 'IndexStored/applyTx');
|
||||
|
||||
Route::any('IndexStored/userCashList', 'IndexStored/userCashList');
|
||||
//二维码
|
||||
Route::any('IndexMember/memberQr', 'IndexMember/memberQr');
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user