王总上门按摩后台代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

251 lines
5.2 KiB

<?php
namespace app\massage\model;
use app\BaseModel;
use app\massage\server\RoleAuth;
use app\mobilenode\model\RoleAdmin;
use think\facade\Db;
class User extends BaseModel
{
//定义表名
protected $name = 'massage_service_user_list';
public function getPhoneAttr($value,$data){
if(!empty($value)&&isset($data['uniacid'])){
if(numberEncryption($data['uniacid'])==1){
return substr_replace($value, "****", 2,4);
}
}
return $value;
}
/**
* @author chenniang
* @DataTime: 2021-08-29 21:18
* @功能说明:
*/
public function getBalanceAttr($value,$data){
if(isset($value)){
return round($value,2);
}
}
/**
* @author chenniang
* @DataTime: 2021-08-29 21:18
* @功能说明:
*/
public function getCashAttr($value,$data){
if(isset($value)){
return round($value,2);
}
}
/**
* @author chenniang
* @DataTime: 2020-09-29 11:04
* @功能说明:添加
*/
public function dataAdd($data){
$data['create_time'] = time();
$data['status'] = 1;
$res = $this->insert($data);
return $res;
}
/**
* @author chenniang
* @DataTime: 2020-09-29 11:05
* @功能说明:编辑
*/
public function dataUpdate($dis,$data){
$res = $this->where($dis)->update($data);
return $res;
}
/**
* @author chenniang
* @DataTime: 2020-09-29 11:06
* @功能说明:列表
*/
public function dataList($dis,$page,$mapor=[],$field='*'){
$data = $this->where($dis) ->where(function ($query) use ($mapor){
$query->whereOr($mapor);
})->field($field)->order('id desc')->paginate($page)->toArray();
return $data;
}
/**
* @author chenniang
* @DataTime: 2020-09-29 11:43
* @功能说明:
*/
public function dataInfo($dis,$field='*'){
$data = $this->where($dis)->field($field)->find();
return !empty($data)?$data->toArray():[];
}
/**
* @author chenniang
* @DataTime: 2020-10-27 15:42
* @功能说明:订单自提码
*/
public function orderQr($input,$uniacid){
$data = longbingCreateWxCode($uniacid,$input,$input['page']);
$data = transImagesOne($data ,['qr_path'] ,$uniacid);
$qr = $data['qr_path'];
return $qr;
}
/**
* @author chenniang
* @DataTime: 2023-05-06 16:40
* @功能说明:获取各类角色的审核结果
*/
public function authCheckData($data){
$auth_server = new RoleAuth();
//技师
$coach_model = new Coach();
//业务员
$salesman_model = new Salesman();
//分销员
$distri_model = new DistributionList();
//渠道商
$channel_model = new ChannelList();
//代理商
$admin_model = new Admin();
//手机操作权限
$role_model = new RoleAdmin();
$auth_server->addObserver($coach_model);
$auth_server->addObserver($salesman_model);
$auth_server->addObserver($distri_model);
$auth_server->addObserver($channel_model);
$auth_server->addObserver($admin_model);
$auth_server->addObserver($role_model);
$data = $auth_server->notify($data);
return $data;
}
/**
* @author chenniang
* @DataTime: 2023-05-19 10:04
* @功能说明:校验技师金额
*/
public function checkCoachCash($coach){
$order_model = new Order();
$wallet_model= new Wallet();
$comm_model = new Commission();
$coach_model = new Coach();
$service = $order_model->where(['pay_type'=>7,'coach_id'=>$coach['id']])->sum('coach_cash');
$balance_cash = $comm_model->where(['top_id'=>$coach['id'],'type'=>7,'status'=>2])->sum('cash');
$wallet_price = $wallet_model->where(['coach_id'=>$coach['id'],'type'=>1])->where('status','in',[1,2])->sum('total_price');
$cash = round($service+$balance_cash-$coach['service_price']-$wallet_price,2);
$coach_model->dataUpdate(['id'=>$coach['id']],['check_cash'=>$cash]);
return true;
}
/**
* @author chenniang
* @DataTime: 2023-05-19 10:32
* @功能说明:校验代理商佣金
*/
public function checkAdminCash($admin){
$comm_model = new Commission();
$admin_model= new Admin();
$wallet_model= new Wallet();
$admin_cash = $comm_model->where(['top_id'=>$admin['id'],'status'=>2])->where('type','in',[2,5,6])->sum('cash');
$wallet_price = $wallet_model->where(['admin_id'=>$admin['id'],'type'=>3])->where('status','in',[1,2])->sum('total_price');
$cash = round($admin_cash-$admin['cash']-$wallet_price,2);
$admin_model->dataUpdate(['id'=>$admin['id']],['check_cash'=>$cash]);
return true;
}
/**
* @author chenniang
* @DataTime: 2023-05-19 18:20
* @功能说明:获取合伙人id
*/
public function getPartnerId($name){
$where[] = ['id','=',$name];
$where[] = ['nickName','like','%'.$name.'%'];
$id = $this->whereOr($where)->column('id');
return $id;
}
}