初始化代码

This commit is contained in:
2025-12-22 14:32:54 +08:00
parent e27ab90d9f
commit d02b31a8b9
1459 changed files with 240973 additions and 0 deletions

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}