初始化代码

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,132 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use app\BaseController;
use think\App;
use app\shop\model\Admin as Model;
use think\facade\Db;
use think\facade\Lang;
use think\Response;
class Admin extends BaseController
{
protected $model;
protected $config_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Model();
}
/**
* @author chenniang
* @DataTime: 2021-03-11 13:53
* @功能说明:登陆
*/
public function login(){
// $input = $this->_input;
initLogin();
$input = json_decode( $this->request->getInput(), true );
//dump($input);exit;
$dis = [
// 'uniacid' => $this->_uniacid,
'username'=> $input['username']
];
$data = $this->model->dataInfo($dis);
if(empty($data)){
return $this->error('该用户不存在', 400);
}
if($data['passwd']!=checkPass($input['passwd'])){
return $this->error('密码错误', 400);
}
$result['user'] = $data;
$result['token'] = uuid();
if (empty($result['token'])) {
return $this->error('系统错误', 400);
}
//添加缓存数据
setUserForToken($result['token'], $data, 99999999);
return $this->success($result);
}
public function success ( $data, $code = 200 )
{
$result[ 'data' ] = $data;
$result[ 'code' ] = $code;
$result[ 'sign' ] = null;
//复杂的签名
// if(isset($this->_user['keys'])){
// $result['sign'] = rsa2CreateSign($this->_user['keys'] ,json_encode($data));
// }
//简单的签名
if ( !empty( $this->_token ) ) $result[ 'sign' ] = createSimpleSign( $this->_token, is_string( $data ) ? $data : json_encode( $data ) );
return $this->response( $result, 'json', $code );
}
//返回错误数据
public function error ( $msg, $code = 400 )
{
$result[ 'error' ] = Lang::get($msg);
$result[ 'code' ] = $code;
return $this->response( $result, 'json', 200 );
}
/**
* 输出返回数据
* @access protected
* @param mixed $data 要返回的数据
* @param String $type 返回类型 JSON XML
* @param integer $code HTTP状态码
* @return Response
*/
protected function response ( $data, $type = 'json', $code = 200 )
{
return Response::create( $data, $type )->code( $code );
}
}

View File

@@ -0,0 +1,441 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use app\massage\model\CarAtvContent;
use app\massage\model\CarAtvList;
use app\massage\model\CarAtvRecord;
use app\massage\model\CarDriver;
use app\massage\model\CarGame;
use app\massage\model\User;
use think\App;
use think\facade\Db;
class AdminAtv extends AdminRest
{
protected $model;
protected $content_model;
protected $record_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new CarAtvList();
$this->content_model = new CarAtvContent();
$this->record_model = new CarAtvRecord();
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:28
* @功能说明:内容列表
*/
public function contentList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
$data = $this->content_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:28
* @功能说明:内容列表
*/
public function contentSelect(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',1];
$data = $this->content_model->where($dis)->order('id desc')->select()->toArray();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:28
* @功能说明:详情
*/
public function contentInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->content_model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:29
* @功能说明:添加活动详情
*/
public function contentAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$data = $this->content_model->dataAdd($input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:29
* @功能说明:编辑活动详情
*/
public function contentUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
if(isset($input['status'])&&in_array($input['status'],[-1,0])){
$find = $this->model->atvContentIng($input['id']);
if(!empty($find)){
$this->errorMsg('该内容正在被使用');
}
}
$data = $this->content_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:28
* @功能说明:内容列表
*/
public function atvList(){
$input = $this->_param;
$this->model->initAtv();
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
if(!empty($input['status'])){
$dis[] = ['atv_status','=',$input['status']];
}
$data = $this->model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:28
* @功能说明:详情
*/
public function atvInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:29
* @功能说明:添加活动详情
*/
public function atvAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$data = $this->model->dataAdd($input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:29
* @功能说明:编辑活动详情
*/
public function atvUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$input['uniacid'] = $this->_uniacid;
$info = $this->model->dataInfo($dis);
if(isset($input['atv_num'])&&$input['atv_num']<$info['have_num']){
$this->errorMsg('报名人数不能小于已经报名人数,已报名'.$info['have_num']);
}
$data = $this->model->dataUpdate($dis,$input);
if(!empty($input['atv_s_time'])&&!empty($input['atv_e_time'])){
//同步活动报名时间
$update = [
'start_time' => $input['atv_s_time'],
'end_time' => $input['atv_e_time'],
];
$this->record_model->dataUpdate(['atv_id'=>$input['id']],$update);
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-16 15:41
* @功能说明:用户报名列表
*/
public function recordList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
if(!empty($input['status'])){
$dis[] = ['b.atv_status','=',$input['status']];
}
if(!empty($input['pay_type'])){
$dis[] = ['a.pay_type','=',$input['pay_type']];
}
if(!empty($input['start_time'])&&!empty($input['end_time'])){
$dis[] = ['a.pay_time','between',"{$input['start_time']},{$input['end_time']}"];
}
if(!empty($input['id'])){
$dis[] = ['a.atv_id','=',$input['id']];
}
$data = $this->record_model->atvRecordList($dis,$input['limit'],[],$input['rank']);
if(!empty($data['data'])){
$user_model = new User();
$driver_model = new CarDriver();
$page = ($data['current_page']-1)*$data['per_page'];
foreach ($data['data'] as $k=>&$v){
$v['nickName'] = $user_model->where(['id'=>$v['user_id']])->value('nickName');
$v['phone'] = $user_model->where(['id'=>$v['user_id']])->value('phone');
$v['avatarUrl'] = $user_model->where(['id'=>$v['user_id']])->value('avatarUrl');
$v['user_name'] = $driver_model->where(['user_id'=>$v['user_id']])->value('user_name');
// $v['game_info']['top'] = $v['pay_type']==7?$page+$k+1:0;
$v['game_info']['top'] = $this->record_model->getRecordTop($v);
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-16 15:46
* @功能说明:报名详情
*/
public function recordInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data['record_info'] = $this->record_model->dataInfo($dis);
$data['record_info']['create_time'] = date('Y-m-d H:i:s',$data['record_info']['create_time']);
$atv_model = new CarAtvList();
$driver_model = new CarDriver();
$data['atv_info'] = $atv_model->dataInfo(['id'=>$data['record_info']['atv_id']]);
$user_model = new User();
$data['record_info']['nickName'] = $user_model->where(['id'=>$data['record_info']['user_id']])->value('nickName');
$data['record_info']['avatarUrl'] = $user_model->where(['id'=>$data['record_info']['user_id']])->value('avatarUrl');
$data['record_info']['phone'] = $user_model->where(['id'=>$data['record_info']['user_id']])->value('phone');
$data['record_info']['user_name'] = $driver_model->where(['user_id'=>$data['record_info']['user_id']])->value('user_name');
$data['record_info']['game_info']['top'] = $this->record_model->getRecordTop($data['record_info']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:29
* @功能说明:编辑
*/
public function recordUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$input['uniacid'] = $this->_uniacid;
$data = $this->record_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-10-20 10:30
* @功能说明:比赛情况列表
*/
public function gameList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
$dis[] = ['a.have_game','=',1];
if(!empty($input['name'])){
$dis[] = ['b.nickName','like','%'.$input['name'].'%'];
}
if(!empty($input['major'])){
$dis[] = ['a.major','=',$input['major']];
}
if(!empty($input['start_time'])){
$dis[] = ['a.start_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$game_model = new CarGame();
$data = $game_model->topRecordList($dis,$input['limit']);
return $this->success($data);
}
}

View File

@@ -0,0 +1,203 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use app\massage\model\BalanceCard;
use app\massage\model\BalanceOrder;
use app\massage\model\Coupon;
use app\shop\model\Article;
use app\shop\model\Banner;
use app\shop\model\Cap;
use app\shop\model\Date;
use app\shop\model\MsgConfig;
use app\shop\model\OrderAddress;
use app\shop\model\OrderGoods;
use app\shop\model\RefundOrder;
use app\shop\model\RefundOrderGoods;
use app\shop\model\Wallet;
use think\App;
use app\shop\model\Order as Model;
use think\facade\Db;
class AdminBalance extends AdminRest
{
protected $model;
protected $order_model;
protected $refund_order_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new BalanceCard();
$this->order_model = new BalanceOrder();
$this->refund_order_model = new RefundOrder();
}
/**
* @author chenniang
* @DataTime: 2021-07-04 19:09
* @功能说明:储值充值卡列表
*/
public function cardList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['name'])){
$dis[] = ['title','like','%'.$input['name'].'%'];
}
$data = $this->model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:56
* @功能说明:添加充值卡
*/
public function cardAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$res = $this->model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:57
* @功能说明:编辑充值卡
*/
public function cardUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$res = $this->model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:59
* @功能说明:充值卡详情
*/
public function cardInfo(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$res = $this->model->dataInfo($dis);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 19:09
* @功能说明:储值订单列表
*/
public function orderList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',1];
if(!empty($input['name'])){
$dis[] = ['title','like','%'.$input['name'].'%'];
}
if(!empty($input['order_code'])){
$dis[] = ['order_code','like','%'.$input['order_code'].'%'];
}
if(!empty($input['start_time'])){
$dis[] = ['pay_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$data = $this->order_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:59
* @功能说明:充值订单详情
*/
public function orderInfo(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$res = $this->order_model->dataInfo($dis);
return $this->success($res);
}
}

View File

@@ -0,0 +1,239 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use app\massage\model\Coupon;
use app\massage\model\CouponAtv;
use app\massage\model\CouponAtvRecord;
use app\massage\model\CouponRecord;
use app\shop\model\Article;
use app\shop\model\Banner;
use app\shop\model\Cap;
use app\shop\model\Date;
use app\shop\model\MsgConfig;
use app\shop\model\OrderAddress;
use app\shop\model\OrderGoods;
use app\shop\model\RefundOrder;
use app\shop\model\RefundOrderGoods;
use app\shop\model\Wallet;
use think\App;
use app\shop\model\Order as Model;
use think\facade\Db;
class AdminCoupon extends AdminRest
{
protected $model;
protected $atv_model;
protected $record_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Coupon();
$this->atv_model = new CouponAtv();
$this->record_model = new CouponRecord();
}
/**
* @author chenniang
* @DataTime: 2021-07-04 19:09
* @功能说明:优惠券列表
*/
public function couponList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
if(!empty($input['status'])){
$dis[] = ['status','=',$input['status']];
}else{
$dis[] = ['status','>',-1];
}
if(isset($input['send_type'])){
$dis[] = ['send_type','=',$input['send_type']];
}
if(!empty($input['name'])){
$dis[] = ['title','like','%'.$input['name'].'%'];
}
$data = $this->model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:56
* @功能说明:添加优惠券
*/
public function couponAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$res = $this->model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:57
* @功能说明:编辑优惠券
*/
public function couponUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$input['uniacid'] = $this->_uniacid;
//删除优惠券 需要判断该优惠券是否正在参加活动
if(isset($input['status'])&&$input['status']==-1){
$atv_record_model = new CouponAtvRecord();
$have_atv = $atv_record_model->couponIsAtv($input['id']);
if($have_atv==true){
$this->errorMsg('该优惠券正在参加活动,只有等用户发起等活动结束后才能删除');
}
}
$res = $this->model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:59
* @功能说明:优惠券详情
*/
public function couponInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$res = $this->model->dataInfo($dis);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-06 19:19
* @功能说明:活动详情
*/
public function couponAtvInfo(){
$input = $this->_param;
$dis = [
'uniacid' => $this->_uniacid
];
$data = $this->atv_model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-06 19:22
* @功能说明:活动编辑
*/
public function couponAtvUpdate(){
$input = $this->_input;
$dis = [
'uniacid' => $this->_uniacid
];
$input['uniacid'] = $this->_uniacid;
$data = $this->atv_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-12 16:26
* @功能说明:后台派发卡劵
*/
public function couponRecordAdd(){
$input = $this->_input;
foreach ($input['user'] as $value){
$res = $this->record_model->recordAdd($input['coupon_id'],$value['id'],$value['num']);
if(!empty($res['code'])){
$this->errorMsg($res['msg']);
}
}
return $this->success($res);
}
}

View File

@@ -0,0 +1,647 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use app\massage\model\CarAtvList;
use app\massage\model\CarDriver;
use app\massage\model\CarTrophy;
use app\massage\model\CarType;
use app\massage\model\CarUserTrophy;
use app\massage\model\Coach;
use app\massage\model\CoachLevel;
use app\massage\model\Goods;
use app\massage\model\Order;
use app\massage\model\Police;
use app\massage\model\User;
use app\member\model\Level;
use app\restaurant\model\GoodsCate;
use app\restaurant\model\GoodsSpe;
use app\shop\model\Wallet;
use longbingcore\wxcore\PospalApi;
use longbingcore\wxcore\WxPay;
use think\App;
use app\shop\model\Order as Model;
use think\facade\Db;
class AdminDriver extends AdminRest
{
protected $model;
protected $order_goods_model;
protected $trophy_model;
protected $car_type_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new CarDriver();
$this->car_type_model = new CarType();
//
$this->trophy_model = new CarTrophy();
}
/**
* @author chenniang
* @DataTime: 2021-03-15 14:43
* @功能说明:列表
*/
public function driverList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
if(!empty($input['status'])){
$dis[] = ['a.status','=',$input['status']];
}else{
$dis[] = ['a.status','>',-1];
}
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"];
}
$where = [];
if(!empty($input['name'])){
$where[] = ['user_name','like','%'.$input['name'].'%'];
$where[] = ['mobile','like','%'.$input['name'].'%'];
}
$data = $this->model->dataList($dis,$input['limit'],$where);
$list = [
'0'=>'all',
1=>'ing',
2=>'pass',
4=>'nopass'
];
foreach ($list as $k=> $value){
$dis_s = [];
$dis_s[] =['uniacid','=',$this->_uniacid];
if(!empty($k)){
$dis_s[] = ['status','=',$k];
}else{
$dis_s[] = ['status','>',-1];
}
$data[$value] = $this->model->where($dis_s)->count();
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-15 14:58
* @功能说明:车手详情
*/
public function driverInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->model->dataInfo($dis);
$user_model = new User();
$data['nickName'] = $user_model->where(['id'=>$data['user_id']])->value('nickName');
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-03 00:15
* @功能说明:审核(2通过,3取消,4拒绝)
*/
public function driverUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
if(!empty($input['status'])&&in_array($input['status'],[2,4])){
$input['sh_time'] = time();
}
$data = $this->model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:53
* @功能说明:奖杯列表
*/
public function trophyList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
$data = $this->trophy_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:53
* @功能说明:奖杯列表
*/
public function trophySelect(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',1];
if(!empty($input['user_id'])){
$user_t_model = new CarUserTrophy();
$id = $user_t_model->where(['user_id'=>$input['user_id']])->column('trophy_id');
$dis[] = ['id','in',$id];
}
$data = $this->trophy_model->where($dis)->select()->toArray();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:56
* @功能说明:添加奖杯
*/
public function trophyAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$res = $this->trophy_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:57
* @功能说明:编辑奖杯
*/
public function trophyUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$res = $this->trophy_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:59
* @功能说明:奖杯详情
*/
public function trophyInfo(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$res = $this->trophy_model->dataInfo($dis);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:53
* @功能说明:车型列表
*/
public function cartypeSelect(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',1];
$data = $this->car_type_model->where($dis)->select()->toArray();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:53
* @功能说明:车型列表
*/
public function cartypeList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
$data = $this->car_type_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:56
* @功能说明:添加车型
*/
public function cartypeAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$res = $this->car_type_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:57
* @功能说明:编辑车型
*/
public function cartypeUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
//删除
if(isset($input['status'])&&in_array($input['status'],[-1,0])){
$goods_model = new Goods();
$goods = $goods_model->carTypeHave($input['id']);
if(!empty($goods)){
$this->errorMsg('产品:'.$goods['title'].' 正在使用该车型,无法删除或下架');
}
$atv_model = new CarAtvList();
$atv = $atv_model->where(['car_type_id'=>$input['id']])->where('status','>',-1)->find();
if(!empty($atv)){
$atv = $atv->toArray();
$this->errorMsg('活动:'.$atv['title'].' 正在使用该车型,无法删除或下架');
}
}
$res = $this->car_type_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:59
* @功能说明:车型详情
*/
public function cartypeInfo(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$res = $this->car_type_model->dataInfo($dis);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-07 18:46
* @功能说明:提现列表
*/
public function walletList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
$dis[] = ['a.type','=',$input['type']];
if(!empty($input['code'])){
$dis[] = ['a.code','like','%'.$input['code'].'%'];
}
if(!empty($input['status'])){
$dis[] = ['a.status','=',$input['status']];
}
$data = $this->wallet_model->adminList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-07 18:57
* @功能说明:提现详情
*/
public function walletInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->wallet_model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-07 18:58
* @功能说明:通过提现申请
*/
public function walletPass(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$data = $this->wallet_model->dataInfo($dis);
if($data['status']!=1){
$this->errorMsg('申请已审核');
}
$update = [
'sh_time' => time(),
//'text' => !empty($input['text'])?$input['text']:'',
'status' => 2,
'online' => $input['online'],
'true_price'=> $data['apply_price']
];
Db::startTrans();
$res = $this->wallet_model->dataUpdate(['id'=>$input['id'],'status'=>1],$update);
if($res!=1){
Db::rollback();
$this->errorMsg('打款失败');
}
//线上转账
if($input['online']==1){
$user_model = new \app\massage\model\User();
$openid = $user_model->where(['id'=>$data['user_id']])->value('openid');
if(empty($openid)){
return $this->error('用户信息错误未获取到openid');
}
//微信相关模型
$wx_pay = new WxPay($this->_uniacid);
//微信提现
$res = $wx_pay->crteateMchPay($this->payConfig(),$openid,$update['true_price']);
if($res['result_code']=='SUCCESS'&&$res['return_code']=='SUCCESS'){
if(!empty($res['payment_no'])){
$this->wallet_model->dataUpdate(['id'=>$input['id']],['payment_no'=>$res['payment_no']]);
}
}else{
Db::rollback();
return $this->error(!empty($res['err_code_des'])?$res['err_code_des']:'你还未该权限');
}
}
Db::commit();
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-26 15:03
* @功能说明:决绝提现
*/
public function walletNoPass(){
$input = $this->_input;
$info = $this->wallet_model->dataInfo(['id'=>$input['id']]);
if($info['status']==2){
$this->errorMsg('已同意打款');
}
if($info['status']==3){
$this->errorMsg('已拒绝打款');
}
Db::startTrans();
$update = [
'sh_time' => time(),
//'text' => !empty($input['text'])?$input['text']:'',
'status' => 3,
];
$res = $this->wallet_model->dataUpdate(['id'=>$input['id'],'status'=>1],$update);
if($res!=1){
Db::rollback();
$this->errorMsg('打款失败');
}
$cap_info = $this->model->dataInfo(['id'=>$info['coach_id']]);
if($info['type']==1){
$res = $this->model->dataUpdate(['id'=>$info['coach_id']],['service_price'=>$cap_info['service_price']+$info['total_price']]);
}else{
$res = $this->model->dataUpdate(['id'=>$info['coach_id']],['car_price'=>$cap_info['car_price']+$info['total_price']]);
}
if($res!=1){
Db::rollback();
$this->errorMsg('审核失败');
}
Db::commit();
return $this->success($res);
}
}

View File

@@ -0,0 +1,287 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use app\massage\model\Article;
use app\massage\model\Cap;
use app\massage\model\Date;
use app\massage\model\OrderGoods;
use app\massage\model\RefundOrder;
use app\massage\model\Wallet;
use longbingcore\wxcore\Excel;
use think\App;
use app\massage\model\Order as Model;
class AdminExcel extends AdminRest
{
protected $model;
protected $order_goods_model;
protected $refund_order_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Model();
$this->order_goods_model = new OrderGoods();
$this->refund_order_model = new RefundOrder();
}
/**
* @author chenniang
* @DataTime: 2021-03-15 14:43
* @功能说明:列表
*/
public function orderList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
//时间搜素
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['goods_name'])){
$dis[] = ['b.goods_name','like','%'.$input['goods_name'].'%'];
}
//手机号搜索
if(!empty($input['mobile'])){
$dis[] = ['a.mobile','like','%'.$input['mobile'].'%'];
}
if(!empty($input['pay_type'])){
//订单状态搜索
$dis[] = ['a.pay_type','=',$input['pay_type']];
}
//除开删除的
$dis[] = ['a.is_show','=',1];
if(!empty($input['order_code'])){
$dis[] = ['a.order_code','like','%'.$input['order_code'].'%'];
}
$data = $this->model->adminDataSelect($dis,$input['limit']);
$name = '订单列表';
$header=[
'订单ID',
'产品',
'产品价格',
'数量',
'下单人',
'手机号',
// '服务项目费用',
'实收金额',
'系统订单号',
'付款订单号',
'下单时间',
'支付方式',
'状态',
];
$new_data = [];
foreach ($data as $v){
$info = array();
$info[] = $v['id'];
$info[] = $v['goods_name'];
$info[] = $v['goods_price'];
$info[] = $v['num'];
$info[] = $v['nickName'];
$info[] = $v['mobile'];
// $info[] = $v['init_service_price'];
$info[] = $v['pay_price'];
$info[] = $v['order_code'];
$info[] = $v['transaction_id'];
$info[] = date('Y-m-d H:i:s',$v['create_time']);
$info[] = !empty($v['balance'])?'余额支付':'微信支付';
$info[] = $this->orderStatusText($v['pay_type']);
$new_data[] = $info;
}
$excel = new Excel();
$excel->excelExport($name,$header,$new_data,'',1);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-30 16:32
* @功能说明:
*/
public function orderStatusText($status){
switch ($status){
case 1:
return '待支付';
break;
case 2:
return '待签到';
break;
case 3:
return '待核销';
break;
case 7:
return '已完成';
break;
case -1:
return '已取消';
break;
}
}
/**
* @author chenniang
* @DataTime: 2021-03-18 13:37
* @功能说明:财务数据统计导出
*/
public function dateCount(){
$input = $this->_param;
$cap_id = $input['cap_id'];
$date_model = new Date();
$wallet_model = new Wallet();
$cap_model = new Cap();
$date_model->dataInit($this->_uniacid);
$dis[] = ['uniacid','=',$this->_uniacid];
//时间搜素
if(!empty($input['start_time'])&&!empty($input['end_time'])){
$start_time = $input['start_time'];
$end_time = $input['end_time'];
$dis[] = ['date_str','between',"$start_time,$end_time"];
}
$date_list = $date_model->dataList($dis,100000);
//店铺名字
$store_name = $cap_model->where(['id'=>$cap_id])->value('store_name');
//开始时间结束时间
if(!empty($start_time)){
$date_list['start_time'] = $start_time;
$date_list['end_time'] = $end_time;
}else{
$date_list['start_time'] = $date_model->where(['uniacid'=>$this->_uniacid])->min('date_str');
$date_list['end_time'] = $date_model->where(['uniacid'=>$this->_uniacid])->max('date_str');
}
if(!empty($date_list['data'])){
foreach ($date_list['data'] as $k=>$v){
//订单金额
$date_list['data'][$k]['order_price'] = $this->model->datePrice($v['date_str'],$this->_uniacid,$cap_id);
//退款金额
$date_list['data'][$k]['refund_price'] = $this->refund_order_model->datePrice($v['date_str'],$this->_uniacid,$cap_id);
//提现金额
$date_list['data'][$k]['wallet_price'] = $wallet_model->datePrice($v['date_str'],$this->_uniacid,$cap_id);
}
}
$name = $store_name.'财务报表';
$header=[
'收支时间',
'订单收入',
'订单退款',
'提现(元)',
];
$new_data = [];
foreach ($date_list['data'] as $v){
$info = array();
$info[] = $v['date'];
$info[] = $v['order_price'];
$info[] = $v['refund_price'];
$info[] = $v['wallet_price'];
$new_data[] = $info;
}
$excel = new Excel();
$excel->excelExport($name,$header,$new_data);
return $this->success($date_list);
}
}

View File

@@ -0,0 +1,629 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use app\massage\model\CarAtvRecord;
use app\massage\model\Comment;
use app\massage\model\CommentLable;
use app\massage\model\Lable;
use app\massage\model\NoticeList;
use app\massage\model\Order;
use app\massage\model\Printer;
use app\massage\model\RefundOrder;
use app\massage\model\User;
use app\shop\model\OrderGoods;
use app\shop\model\Wallet;
use think\App;
use app\shop\model\Order as Model;
use think\facade\Db;
class AdminOrder extends AdminRest
{
protected $model;
protected $order_goods_model;
protected $refund_order_model;
protected $comment_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Order();
$this->order_goods_model = new OrderGoods();
$this->refund_order_model = new RefundOrder();
}
/**
* @author chenniang
* @DataTime: 2021-03-15 14:43
* @功能说明:列表
*/
public function orderList(){
$input = $this->_param;
//超时自动取消订单
// $this->model->autoCancelOrder($this->_uniacid);
$dis[] = ['a.uniacid','=',$this->_uniacid];
//时间搜素
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['goods_name'])){
$dis[] = ['b.goods_name','like','%'.$input['goods_name'].'%'];
}
//手机号搜索
if(!empty($input['mobile'])){
$dis[] = ['a.mobile','like','%'.$input['mobile'].'%'];
}
if(!empty($input['pay_type'])){
//订单状态搜索
$dis[] = ['a.pay_type','=',$input['pay_type']];
}
// //除开删除的
$dis[] = ['a.is_show','=',1];
if(!empty($input['order_code'])){
$dis[] = ['a.order_code','like','%'.$input['order_code'].'%'];
}
$data = $this->model->adminDataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-15 14:58
* @功能说明:订单详情
*/
public function orderInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->model->dataInfo($dis);
$user_model = new User();
$data['nickName'] = $user_model->where(['id'=>$data['user_id']])->value('nickName');
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 17:50
* @功能说明:退款订单详情
*/
public function refundOrderInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->refund_order_model->dataInfo($dis);
$data['pay_order_code'] = $this->model->where(['id'=>$data['order_id']])->value('order_code');
$data['create_time'] = date('Y-m-d H:i:s',$data['create_time']);
$data['refund_time'] = date('Y-m-d H:i:s',$data['refund_time']);
$user_model = new User();
$data['nickName'] = $user_model->where(['id'=>$data['user_id']])->value('nickName');
$data['mobile'] = $this->model->where(['id'=>$data['order_id']])->value('mobile');
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-17 17:44
* @功能说明:退款订单列表
*/
public function refundOrderList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
//商品名字搜索
if(!empty($input['goods_name'])){
$dis[] = ['c.goods_name','like','%'.$input['goods_name'].'%'];
}
//订单状态搜索
if(!empty($input['status'])){
$dis[] = ['a.status','=',$input['status']];
}else{
$dis[] = ['a.status','>',-1];
}
$where = [];
if(!empty($input['order_code'])){
$where[] = ['a.order_code','like','%'.$input['order_code'].'%'];
$where[] = ['d.order_code','like','%'.$input['order_code'].'%'];
}
$data = $this->refund_order_model->adminDataList($dis,$input['limit'],$where);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-18 09:21
* @功能说明:拒绝退款
*/
public function noPassRefund(){
$input = $this->_input;
$res = $this->refund_order_model->noPassRefund($input['id']);
if(!empty($res['code'])){
$this->errorMsg($res['msg']);
}
return $this->success($res);
}
/**\
* @author chenniang
* @DataTime: 2021-03-18 09:28
* @功能说明:同意退款
*/
public function passRefund(){
$input = $this->_input;
$res = $this->refund_order_model->passOrder($input['id'],$input['price'],$this->payConfig(),0,$input['text']);
if(!empty($res['code'])){
$this->errorMsg($res['msg']);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-05 23:16
* @功能说明:评价列表
*/
public function commentList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
$dis[] = ['a.status','>',-1];
if(!empty($input['star'])){
$dis[] = ['a.star','=',$input['star']];
}
if(!empty($input['coach_name'])){
$dis[] = ['d.coach_name','like','%'.$input['coach_name'].'%'];
}
if(!empty($input['goods_name'])){
$dis[] = ['c.goods_name','like','%'.$input['goods_name'].'%'];
}
$data = $this->comment_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-05 23:31
* @功能说明:编辑评价
*/
public function commentUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$data = $this->comment_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:53
* @功能说明:评价标签列表
*/
public function commentLableList(){
$input = $this->_param;
$lable_model = new Lable();
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
$data = $lable_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:56
* @功能说明:添加评价标签
*/
public function commentLableAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$lable_model = new Lable();
$res = $lable_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:57
* @功能说明:编辑评价标签
*/
public function commentLableUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$lable_model = new Lable();
$res = $lable_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-04 18:59
* @功能说明:评价标签详情
*/
public function commentLableInfo(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$lable_model = new Lable();
$res = $lable_model->dataInfo($dis);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-16 10:27
* @功能说明:提示列表
*/
public function noticeList(){
$input = $this->_param;
$notice_model = new NoticeList();
$dis[] = ['uniacid','=',$this->_uniacid];
if(!empty($input['type'])){
$dis[] = ['type','=',$input['type']];
}
if(isset($input['have_look'])){
$dis[] = ['have_look','=',$input['have_look']];
}else{
$dis[] = ['have_look','>',-1];
}
if(!empty($input['start_time'])){
$dis[] = ['create_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$data = $notice_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-16 10:38
* @功能说明:未查看的数量
*/
public function noLookCount(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['have_look','=',0];
$notice_model = new NoticeList();
$data = $notice_model->where($dis)->count();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-16 10:41
* @功能说明:全部已读
*/
public function allLook(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['have_look','=',0];
$notice_model = new NoticeList();
$data = $notice_model->dataUpdate($dis,['have_look'=>1]);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-16 10:28
* @功能说明:
*/
public function noticeUpdate(){
$input = $this->_input;
$notice_model = new NoticeList();
$data = $notice_model->dataUpdate(['id'=>$input['id']],$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-11-11 16:26
* @功能说明:订单打印
*/
public function orderPrinter(){
$input = $this->_input;
$printer_model = new Printer();
$res = $printer_model->printer($input['id'],0,$input['type']);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-11-12 15:25
* @功能说明:后台数据统计
*/
public function dataStatistics(){
$input = $this->_input;
$car_order_model = new Order();
$record_model = new CarAtvRecord();
$shop_order_model = new \app\shop\model\Order();
$restaurant_order_model = new \app\restaurant\model\Order();
$dis[] =['pay_type','>',1];
$dis[] =['uniacid','=',$this->_uniacid];
$car_order_price = $car_order_model->where($dis)->sum('pay_price');
$record_price = $record_model->where($dis)->sum('pay_price');
$data['car_price'] = round($car_order_price+$record_price,2);
$shop_price = $shop_order_model->where($dis)->sum('true_price');
$restaurant_price = $restaurant_order_model->where($dis)->sum('true_price');
$data['shop_price'] = round($shop_price,2);
$data['restaurant_price'] = round($restaurant_price,2);
$data['all_price'] = round($car_order_price+$record_price+$shop_price+$restaurant_price,2);
$arr['price'] = $data;
while ($input['date_start_time']<=$input['date_end_time']){
$date[] = date('Y-m-d',$input['date_start_time']);
$input['date_start_time'] +=86400;
}
if(!empty($date)){
foreach ($date as $k=> $value){
$dis = [];
$dis[] =['pay_type','>',1];
$dis[] =['uniacid','=',$this->_uniacid];
$car_order_price = $car_order_model->where($dis)->whereDay('pay_time',$value)->sum('pay_price');
$record_price = $record_model->where($dis)->whereDay('pay_time',$value)->sum('pay_price');
$arr['date'][$k]['car_price']= round($car_order_price+$record_price,2);
$shop_price = $shop_order_model->where($dis)->whereDay('pay_time',$value)->sum('true_price');
$restaurant_price = $restaurant_order_model->where($dis)->whereDay('pay_time',$value)->sum('true_price');
$arr['date'][$k]['shop_price'] = round($shop_price,2);
$arr['date'][$k]['restaurant_price'] = round($restaurant_price,2);
$arr['date'][$k]['all_price'] = round($car_order_price+$record_price+$shop_price+$restaurant_price,2);
$arr['date'][$k]['date'] = $value;
}
}
$arr['date'] = array_values($arr['date']);
$dis[] =['pay_type','>',1];
$dis[] =['uniacid','=',$this->_uniacid];
if(!empty($input['start_time'])){
$dis[] =['pay_time','between',"{$input['start_time']},{$input['end_time']}"];
}
if($input['type']==1){
$arr['order_list'] = $car_order_model->where($dis)->field('id,order_code,pay_price,pay_time')->order('id desc')->paginate($input['limit'])->toArray();
}elseif($input['type']==2){
$arr['order_list'] = $shop_order_model->where($dis)->field('id,order_code,true_price as pay_price,pay_time')->order('id desc')->paginate($input['limit'])->toArray();
}else{
$arr['order_list'] = $restaurant_order_model->where($dis)->field('id,order_code,true_price as pay_price,pay_time')->order('id desc')->paginate($input['limit'])->toArray();
}
return $this->success($arr);
}
}

View File

@@ -0,0 +1,120 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use think\App;
use app\massage\model\Printer as model;
use think\facade\Db;
class AdminPrinter extends AdminRest
{
protected $model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Model();
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:28
* @功能说明:详情
*/
public function printerList(){
$input = $this->_param;
// $dis = [
//
// 'uniacid' => $this->_uniacid
// ];
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
$data = $this->model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:28
* @功能说明:详情
*/
public function printerInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:29
* @功能说明:编辑
*/
public function printerAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$data = $this->model->dataAdd($input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2020-09-29 13:29
* @功能说明:编辑
*/
public function printerUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$data = $this->model->dataUpdate($dis,$input);
return $this->success($data);
}
}

View File

@@ -0,0 +1,148 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use app\massage\model\Goods;
use app\massage\model\Service;
use app\shop\model\Article;
use app\shop\model\Banner;
use app\shop\model\Cap;
use app\shop\model\GoodsCate;
use app\shop\model\GoodsSh;
use app\shop\model\GoodsShList;
use think\App;
use app\shop\model\Goods as Model;
use think\Db;
class AdminService extends AdminRest
{
protected $model;
protected $goods_sh;
protected $goods_sh_list;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Goods();
}
/**
* @author chenniang
* @DataTime: 2021-03-15 14:43
* @功能说明:商品列表
*/
public function serviceList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
if(!empty($input['status'])){
$dis[] = ['status','=',$input['status']];
}else{
$dis[] = ['status','>',-1];
}
if(!empty($input['name'])){
$dis[] = ['title','like','%'.$input['name'].'%'];
}
$data = $this->model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-15 14:58
* @功能说明:审核详情
*/
public function serviceInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-03 00:27
* @功能说明:添加
*/
public function serviceAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$res = $this->model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-03 00:27
* @功能说明:添加
*/
public function serviceUpdate(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$dis = [
'id' => $input['id']
];
$res = $this->model->dataUpdate($dis,$input);
return $this->success($res);
}
}

View File

@@ -0,0 +1,554 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use app\massage\model\CarPrice;
use app\massage\model\Lable;
use app\massage\model\Article;
use app\massage\model\Banner;
use app\massage\model\MsgConfig;
use app\massage\model\PayConfig;
use think\App;
use app\massage\model\Config as Model;
class AdminSetting extends AdminRest
{
protected $model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Model();
}
/**
* @author chenniang
* @DataTime: 2021-03-12 15:04
* @功能说明:配置详情
*/
public function configInfo(){
$dis = [
'uniacid' => $this->_uniacid
];
$data = $this->model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-12 16:14
* @功能说明:编辑配置
*/
public function configUpdate(){
$input = $this->_input;
$dis = [
'uniacid' => $this->_uniacid
];
$data = $this->model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-12 16:15
* @功能说明:banner列表
*/
public function bannerList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
$banner_model = new Banner();
$data = $banner_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-12 16:18
* @功能说明:添加banner
*/
public function bannerAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$banner_model = new Banner();
$res = $banner_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-12 16:20
* @功能说明:编辑banner
*/
public function bannerUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$banner_model = new Banner();
$res = $banner_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 13:27
* @功能说明:banner详情
*/
public function bannerInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$banner_model = new Banner();
$res = $banner_model->dataInfo($dis);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-18 10:53
* @功能说明:支付配置详情
*/
public function payConfigInfo(){
$dis = [
'uniacid' => $this->_uniacid
];
$pay_model = new PayConfig();
$data = $pay_model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-18 10:55
* @功能说明:编辑支付配置
*/
public function payConfigUpdate(){
$input = $this->_input;
$dis = [
'uniacid' => $this->_uniacid
];
if(isset($input['cert_path'])&&isset($input['key_path'])){
if(!strstr($input['cert_path'],FILE_UPLOAD_PATH)){
$input['cert_path'] = FILE_UPLOAD_PATH.$input['cert_path'];
}
if(!strstr($input['key_path'],FILE_UPLOAD_PATH)){
$input['key_path'] = FILE_UPLOAD_PATH.$input['key_path'];
}
}
$pay_model = new PayConfig();
$data = $pay_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-31 15:16
* @功能说明:修改密码
*/
public function updatePass(){
$input = $this->_input;
$admin = new \app\shop\model\Admin();
$update = [
'passwd' => checkPass($input['pass']),
];
$res = $admin->dataUpdate(['uniacid'=>$this->_uniacid],$update);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-12 15:04
* @功能说明:配置详情
*/
public function msgConfigInfo(){
$msg_model = new MsgConfig();
$dis = [
'uniacid' => $this->_uniacid
];
$data = $msg_model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-12 16:14
* @功能说明:编辑配置
*/
public function msgConfigUpdate(){
$input = $this->_input;
$msg_model = new MsgConfig();
$dis = [
'uniacid' => $this->_uniacid
];
$data = $msg_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-05 23:09
* @功能说明:评价标签列表
*/
public function lableList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
$lable_model = new Lable();
$data = $lable_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-05 23:09
* @功能说明:评价标签详情
*/
public function lableInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$lable_model = new Lable();
$data = $lable_model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-05 23:09
* @功能说明:添加评价标签
*/
public function lableAdd(){
$input = $this->_input;
$input['uniacid'] = $this->_uniacid;
$lable_model = new Lable();
$data = $lable_model->dataAdd($input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-05 23:09
* @功能说明:编辑评价标签
*/
public function lableUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$lable_model = new Lable();
$data = $lable_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-16 18:46
* @功能说明:车费配置详情
*/
public function carConfigInfo(){
$car_model = new CarPrice();
$dis = [
'uniacid' => $this->_uniacid
];
$data = $car_model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-16 18:46
* @功能说明:车费配置详情
*/
public function carConfigUpdate(){
$input = $this->_input;
$car_model = new CarPrice();
$dis = [
'uniacid' => $this->_uniacid
];
$data = $car_model->dataUpdate($dis,$input);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-12 16:27
* @功能说明:新闻列表
*/
public function articleList(){
$input = $this->_param;
$article_model = new Article();
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','>',-1];
if(!empty($input['title'])){
$dis[] = ['title','like','%'.$input['title'].'%'];
}
if(!empty($input['type'])){
$dis[] = ['type','=',$input['type']];
}
$data = $article_model->dataList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-12 16:37
* @功能说明:添加文章
*
*/
public function articleAdd(){
$input = $this->_input;
$article_model = new Article();
$input['uniacid'] = $this->_uniacid;
$res = $article_model->dataAdd($input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 13:35
* @功能说明:编辑文章
*/
public function articleUpdate(){
$input = $this->_input;
$article_model = new Article();
$dis = [
'id' => $input['id']
];
$res = $article_model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 13:35
* @功能说明:文章详情
*/
public function articleInfo(){
$input = $this->_param;
$article_model = new Article();
$dis = [
'id' => $input['id']
];
$res = $article_model->dataInfo($dis);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 13:50
* @功能说明:文章下拉框
*/
public function articleSelect(){
$input = $this->_param;
$article_model = new Article();
$dis = [
'uniacid' => $this->_uniacid,
'status' => 1
];
$res = $article_model->where($dis)->field('id,title')->select()->toArray();
return $this->success($res);
}
}

View File

@@ -0,0 +1,261 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use app\massage\model\AdminRole;
use app\massage\model\CarUserTrophy;
use app\massage\model\Commission;
use app\shop\model\Article;
use app\shop\model\Banner;
use app\shop\model\Date;
use app\massage\model\OrderGoods;
use app\massage\model\RefundOrder;
use app\shop\model\IntegralLog;
use app\shop\model\Wallet;
use think\App;
use app\massage\model\User as Model;
class AdminUser extends AdminRest
{
protected $model;
protected $order_goods_model;
protected $refund_order_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Model();
$this->order_goods_model = new OrderGoods();
$this->refund_order_model = new RefundOrder();
}
/**
* @author chenniang
* @DataTime: 2021-03-24 10:24
* @功能说明:用户列表
*/
public function userList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
//是否授权
if(!empty($input['type'])){
if($input['type']==1){
$dis[] = ['nickName','=',''];
}else{
$dis[] = ['nickName','<>',''];
}
}
if(isset($input['role'])){
$dis[] = ['role','=',$input['role']];
}
$where = [];
if(!empty($input['nickName'])){
$where[] = ['nickName','like','%'.$input['nickName'].'%'];
$where[] = ['phone','like','%'.$input['nickName'].'%'];
}
if(!empty($input['start_time'])&&!empty($input['end_time'])){
$start_time = $input['start_time'];
$end_time = $input['end_time'];
$dis[] = ['create_time','between',"$start_time,$end_time"];
}
$data = $this->model->dataList($dis,$input['limit'],$where);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-26 14:39
* @功能说明:编辑员工
*/
public function userUpdate(){
$input = $this->_input;
$dis = [
'id' => $input['id']
];
$res = $this->model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-08-28 23:03
* @功能说明:佣金记录
*/
public function commList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
if(!empty($input['status'])){
$dis[] = ['a.status','=',$input['status']];
}
if(!empty($input['top_name'])){
$dis[] = ['c.nickName','like','%'.$input['top_name'].'%'];
}
$comm_model = new Commission();
$data = $comm_model->recordList($dis,$input['limit']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-26 15:02
* @功能说明:用户所有获得的奖杯
*/
public function userTrophy(){
$input = $this->_param;
$user_trophy_model = new CarUserTrophy();
$dis = [
'a.user_id' => $input['user_id'],
'a.status' => 1,
'b.status' => 1
];
$data = $user_trophy_model->alias('a')
->join('shequshop_car_trophy b','a.trophy_id = b.id')
->where($dis)
->field('a.*,b.title,b.cover')
->select()
->toArray();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-26 15:04
* @功能说明:用户添加奖杯
*/
public function userTrophyAdd(){
$input = $this->_input;
$user_trophy_model = new CarUserTrophy();
foreach ($input['user_id'] as $value){
foreach ($input['trophy_id'] as $v){
$dis = [
'user_id' => $value,
'trophy_id'=> $v,
'uniacid' => $this->_uniacid
];
$find = $user_trophy_model->where($dis)->where('status','>',-1)->find();
//增加
if($input['add']==1){
if(empty($find)){
$user_trophy_model->dataAdd($dis);
}
}else{
//减少
if(!empty($find)){
$user_trophy_model->dataUpdate($dis,['status'=>-1]);
}
}
}
}
return $this->success(true);
}
/**
* @author chenniang
* @DataTime: 2022-07-20 16:00
* @功能说明:修改用户积分
*/
public function userIntegralUpdate(){
$input = $this->_input;
$log_model = new IntegralLog();
$type = $input['integral']>0?12:13;
$res = $log_model->integralUserAdd($input['user_id'],$input['integral'],$this->_uniacid,2,$type);
return $this->success($res);
}
}

View File

@@ -0,0 +1,899 @@
<?php
namespace app\massage\controller;
use app\ApiRest;
use app\massage\model\Article;
use app\massage\model\CarAtvContent;
use app\massage\model\CarAtvList;
use app\massage\model\CarAtvRecord;
use app\massage\model\CarDriver;
use app\massage\model\CarGame;
use app\massage\model\CarType;
use app\massage\model\Coach;
use app\massage\model\CoachCollect;
use app\massage\model\Comment;
use app\massage\model\Goods;
use app\massage\model\Order;
use app\massage\model\Service;
use app\Rest;
use app\massage\model\Banner;
use app\massage\model\Car;
use app\massage\model\Config;
use app\massage\model\User;
use think\App;
use think\facade\Db;
use think\Request;
class Index extends ApiRest
{
protected $model;
protected $article_model;
protected $coach_model;
protected $banner_model;
protected $car_model;
protected $record_model;
protected $driver_model;
protected $atv_model;
protected $game_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Goods();
$this->banner_model = new Banner();
$this->car_model = new Car();
$this->game_model = new CarGame();
$this->record_model = new CarAtvRecord();
$this->driver_model = new CarDriver();
$this->atv_model = new CarAtvList();
$this->atv_model->initAtv();
}
/**
* @author chenniang
* @DataTime: 2021-03-23 09:20
* @功能说明:首页
*/
public function index(){
$dis = [
'uniacid' => $this->_uniacid,
'status' => 1
];
$data['banner'] = $this->banner_model->where($dis)->field('id,img,link')->order('top desc,id desc')->select()->toArray();
//所有专业车手
// $user_id = $this->driver_model->where(['status'=>2])->column('user_id');
$where[] = ['a.have_game','=',1];
$where[] = ['a.major','=',1];
$where[] = ['a.type','=',2];
$speed_record = $this->game_model->topRecordList($where,3);
//普通组车手成绩
$data['speed_record'] = $speed_record['data'];
$atv_dis = [
'uniacid' => $this->_uniacid,
//查询已经结束的
'atv_status' => 3,
'status' => 1
];
//查询最近的一个结束的活动
$atv = $this->atv_model->where($atv_dis)->order('atv_e_time desc')->find();
if(!empty($atv)){
$atv = $atv->toArray();
$i_dis = [
'a.atv_id' => $atv['id'],
// 'a.status' => 2
];
//积分排行榜
$data['integral']['record'] = $this->record_model->integralRecordList($i_dis,4);
$data['integral']['record'] = $data['integral']['record']['data'];
//时间
$data['integral']['time'] = date('Y.m.d',$atv['atv_s_time']).'-'.date('Y.m.d',$atv['atv_e_time']);
$data['integral']['atv_id'] = $atv['id'];
}
$atv_diss[] = ['uniacid','=',$this->_uniacid];
$atv_diss[] = ['status','=',1];
$atv_diss[] = ['app_s_time','<',time()];
$atv_diss[] = ['app_e_time','>',time()];
$data['atv'] = $this->atv_model->where($atv_diss)->order('app_s_time')->find();
if(!empty($data['atv'])){
$data['atv'] = $data['atv']->toArray();
$data['atv']['time'] = date('Y.m.d',$data['atv']['atv_s_time']).'-'.date('Y.m.d',$data['atv']['atv_e_time']);
}
$article_model = new Article();
$arr = [
//热点
'1' => 'hot_article',
//赛事
'2' => 'game_article',
];
//获取热点文章和赛事文章
foreach ($arr as $k=>$value){
$dis = [
'type' => $k,
'uniacid' => $this->_uniacid,
'status' => 1
];
$data[$value] = $article_model->where($dis)->order('top desc,id desc')->limit(3)->select()->toArray();
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-16 14:31
* @功能说明:比赛成绩排行版
*/
public function resultTopList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
$dis[] = ['a.have_game','=',1];
//1普通组 2专业组
$dis[] = ['a.major','=',$input['type']];
//预约的不算
$dis[] = ['a.type','=',2];
if(!empty($input['time'])){
$data = $this->game_model->timeTopRecordList($dis,10,$input['time']);
}else{
$data = $this->game_model->topRecordList($dis,10);
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-16 14:52
* @功能说明:所有已经完成的活动
*/
public function successAtvList(){
$input = $this->_param;
$atv_dis[] = ['uniacid','=',$this->_uniacid];
$atv_dis[] = ['status','=',1];
if(!empty($input['title'])){
$atv_dis[] = ['title','like','%'.$input['title'].'%'];
}
if(!empty($input['atv_status'])){
$atv_dis[] = ['atv_status','=',$input['atv_status']];
}
$atv = $this->atv_model->where($atv_dis)->order('atv_s_time ,id desc')->paginate(10)->toArray();
if(!empty($atv['data'])){
foreach ($atv['data'] as &$v){
$v['time'] = date('Y.m.d',$v['atv_s_time']).'-'.date('Y.m.d',$v['atv_e_time']);
$v['app_status'] = 1;
//已经开始
if($v['app_s_time']<time()){
$v['app_status'] = 2;
}
//已经结束
if($v['app_e_time']<time()){
$v['app_status'] = 3;
}
//剩余数量
$v['surplus_num'] = $v['atv_num']-$v['have_num'] ;
$v['surplus_num'] = $v['surplus_num']>0?$v['surplus_num']:0;
}
}
return $this->success($atv);
}
/**
* @author chenniang
* @DataTime: 2021-09-28 17:43
* @功能说明:赛事积分排行榜
*/
public function integralRecordList(){
$input = $this->_param;
$where[] = ['a.uniacid','=',$this->_uniacid];
$where[] = ['a.atv_id','=',$input['atv_id']];
//报名记录情况
$data = $this->record_model->integralRecordList($where,10);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-16 14:55
* @功能说明:活动详情
*/
public function atvInfo(){
$this->record_model->autoCancelRecord();
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->atv_model->dataInfo($dis);
//活动时间
$data['atv_time'] = date('Y.m.d H:i',$data['atv_s_time']).' - '.date('Y.m.d H:i',$data['atv_e_time']);
//报名时间
$data['app_time'] = date('Y.m.d H:i',$data['app_s_time']).' - '.date('Y.m.d H:i',$data['app_e_time']);
$where[] = ['a.uniacid','=',$this->_uniacid];
$where[] = ['a.atv_id','=',$input['id']];
$where[] = ['a.pay_type','>',1];
//报名记录情况
$data['record_list'] = $this->record_model->integralRecordList($where,10);
$re_where[] = ['atv_id','=',$input['id']];
$re_where[] = ['user_id','=',$this->getUserId()];
$re_where[] = ['pay_type','>',0];
$have_app = $this->record_model->dataInfo($re_where);
//自己是否已经报名
$data['have_app'] = !empty($have_app)?1:0;
//
$content_model = new CarAtvContent();
//报名内容
$data['content_text'] = $content_model->where('id','in',$data['content'])->where(['status'=>1])->select()->toArray();
$data['app_status'] = 1;
//已经开始
if($data['app_s_time']<time()){
$data['app_status'] = 2;
}
//已经结束
if($data['app_e_time']<time()){
$data['app_status'] = 3;
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-16 15:01
* @功能说明:报名活动
*/
public function appAtv(){
$input = $this->_input;
$dis = [
'id' => $input['atv_id'],
'status' => 1
];
$atv = $this->atv_model->dataInfo($dis);
if(empty($atv)){
$this->errorMsg('活动已下架');
}
//已经报名人数
$where[] = ['atv_id','=',$input['atv_id']];
//去掉已经删除的
$where[] = ['pay_type','>',0];
$where[] = ['user_id','=',$this->getUserId()];
//查询自己有没有报名过
$user_num = $this->record_model->where($where)->count();
if(!empty($user_num)){
$this->errorMsg('你已报名或有报名订单未支付');
}
//防止并发做了一个简单的锁
if($atv['have_num']>=$atv['atv_num']){
$this->errorMsg('报名人数已满');
}
$car_type_model = new CarType();
$car_type = $car_type_model->dataInfo(['id'=>$atv['car_type_id']]);
if(empty($car_type)){
$this->errorMsg('车型不存在');
}
//查询自己是否是专业车手
$is_major = $this->driver_model->dataInfo(['user_id'=>$this->getUserId(),'status'=>2]);
$is_major = !empty($is_major)?1:0;
//判断车手身份
if($is_major==1&&$car_type['major']==0){
$this->errorMsg('只有普通车手才能报名');
}
//判断车手身份
if($is_major==0&&$car_type['norm']==0){
$this->errorMsg('只有专业车手才能报名');
}
// $config = new Config();
//
// $member_config_model = new \app\member\model\Config();
// $member_config = $member_config_model->configInfo(['uniacid'=>$this->_uniacid]);
Db::startTrans();
$insert = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'atv_id' => $input['atv_id'],
'start_time' => $atv['atv_s_time'],
'end_time' => $atv['atv_e_time'],
'content' => $input['content'],
'order_code' => orderCode(),
'pay_price' => $atv['pay_price'],
'balance' => !empty($input['is_balance'])?$atv['pay_price']:0,
'over_time' => time()+3600,
'car_type_id'=> $atv['car_type_id'],
'number' => $atv['number'],
//付费获得的积分
// 'get_integral'=> empty($input['is_balance'])?floor($atv['pay_price']*$member_config['integral_cash']):0,
];
$res = $this->record_model->dataAdd($insert);
if(empty($res)){
Db::rollback();
$this->errorMsg('报名失败,请重试');
}
$res = $this->atv_model->dataUpdate(['id'=>$insert['atv_id'],'have_num'=>$atv['have_num']],['have_num'=>$atv['have_num']+1]);
if(empty($res)){
Db::rollback();
$this->errorMsg('报名失败,请重试');
}
Db::commit();
//0元支付
if($insert['pay_price']<=0){
$this->record_model->dataResult($insert['order_code'],$insert['order_code']);
return $this->success([]);
}
if(!empty($insert['balance'])){
$user_model = new User();
$user = $user_model->dataInfo(['id'=>$insert['user_id']]);
if($user['balance']<$insert['balance']){
$this->errorMsg('余额不足');
}
$this->record_model->dataResult($insert['order_code'],$insert['order_code']);
return $this->success([]);
}else{
//微信支付
$pay_controller = new IndexWxPay($this->app);
//支付
$jsApiParameters= $pay_controller->createWeixinPay($this->payConfig(),$this->getUserInfo()['openid'],$this->_uniacid,"carAtvApp",['type' => 'carAtvApp' , 'out_trade_no' => $insert['order_code']],$insert['pay_price']);
$arr['pay_list']= $jsApiParameters;
// $id = $this->record_model->getLastInsID();
$arr['record'] = $this->record_model->dataInfo(['order_code'=>$insert['order_code']]);
return $this->success($arr);
}
}
/**
* @author chenniang
* @DataTime: 2021-09-27 10:25
* @功能说明:报名记录重新支付
*/
public function atvRecordRePay(){
$input = $this->_input;
$record = $this->record_model->dataInfo(['id'=>$input['record_id']]);
if($record['pay_type']!=1){
$this->errorMsg('订单已经失效');
}
if(!empty($record['balance'])){
$user_model = new User();
$user = $user_model->dataInfo(['id'=>$record['user_id']]);
if($user['balance']<$record['balance']){
$this->errorMsg('余额不足');
}
$this->record_model->dataResult($record['order_code'],$record['order_code']);
return $this->success([]);
}else{
//微信支付
$pay_controller = new IndexWxPay($this->app);
//支付
$jsApiParameters= $pay_controller->createWeixinPay($this->payConfig(),$this->getUserInfo()['openid'],$this->_uniacid,"carAtvApp",['type' => 'carAtvApp' , 'out_trade_no' => $record['order_code']],$record['pay_price']);
$arr['pay_list']= $jsApiParameters;
return $this->success($arr);
}
}
/**
* @author chenniang
* @DataTime: 2021-09-16 15:57
* @功能说明:文章列表
*/
public function articleList(){
$input = $this->_param;
$article_model = new Article();
$dis = [
'uniacid' => $this->_uniacid,
'status' => 1
];
if(!empty($input['type'])){
$dis['type'] = $input['type'];
}
$data = $article_model->dataList($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-09-16 16:02
* @功能说明:文章详情
*/
public function articleInfo(){
$input = $this->_param;
$article_model = new Article();
$dis = [
'id' => $input['id']
];
$data = $article_model->dataInfo($dis);
$data['create_time'] = date('Y.m.d H:i',$data['create_time']);
$article_model->dataUpdate(['id'=>$input['id']],['iv'=>$data['iv']+1]);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-23 14:16
* @功能说明:获取配置信息
*/
public function configInfo(){
$dis = [
'uniacid' => $this->_uniacid
];
$config_model = new Config();
$config = $config_model->dataInfo($dis);
return $this->success($config);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:07
* @功能说明:购物车信息
*/
public function carInfo(){
$input = $this->_param;
//购物车信息
$car_info = $this->car_model->carPriceAndCount($this->getUserId(),1);
return $this->success($car_info);
}
/**
* @author chenniang
* @DataTime: 2021-07-23 09:48
* @功能说明:再来一单
*/
public function onceMoreOrder(){
$input = $this->_input;
$order_model = new Order();
$order = $order_model->dataInfo(['id'=>$input['order_id']]);
$coach = $this->coach_model->dataInfo(['id'=>$order['coach_id']]);
if($coach['status']!=2||$coach['is_work']==0){
$this->errorMsg('技师未上班');
}
//清空购物车
$this->car_model->where(['user_id'=>$this->getUserId(),'coach_id'=>$order['coach_id']])->delete();
Db::startTrans();
foreach ($order['order_goods'] as $v){
$ser = $this->model->dataInfo(['id'=>$v['goods_id']]);
if(empty($ser)||$ser['status']!=1){
Db::rollback();
$this->errorMsg('服务已经下架');
}
$dis = [
'user_id' => $this->getUserId(),
'uniacid' => $this->_uniacid,
'coach_id' => $order['coach_id'],
'service_id'=> $v['goods_id'],
'num' => $v['num']
];
$res = $this->car_model->dataAdd($dis);
}
Db::commit();
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:46
* @功能说明:添加到购物车
*/
public function addCar(){
$input = $this->_input;
$insert = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'goods_id' => $input['goods_id'],
];
$info = $this->car_model->dataInfo($insert);
//增加数量
if(!empty($info)){
$res = $this->car_model->dataUpdate(['id'=>$info['id']],['num'=>$info['num']+$input['num']]);
}else{
//添加到购物车
$insert['num'] = $input['num'];
$insert['status'] = 1;
$res = $this->car_model->dataAdd($insert);
$id = $this->car_model->getLastInsID();
return $this->success($id);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:54
* @功能说明:删除购物车
*/
public function delCar(){
$input = $this->_input;
$info = $this->car_model->dataInfo(['id'=>$input['id']]);
//加少数量
if($info['num']>$input['num']){
$res = $this->car_model->dataUpdate(['id'=>$info['id']],['num'=>$info['num']-$input['num']]);
}else{
$res = $this->car_model->where(['id'=>$info['id']])->delete();
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-25 10:39
* @功能说明:
*/
public function carUpdate(){
$input = $this->_input;
$res = $this->car_model->where('id','in',$input['id'])->update(['status'=>$input['status']]);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:59
* @功能说明:批量删除购物车
*/
public function delSomeCar(){
$input = $this->_input;
$dis = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
// 'coach_id'=> $input['coach_id'],
];
$res = $this->car_model->where($dis)->delete();
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-05 23:16
* @功能说明:评价列表
*/
public function commentList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
$dis[] = ['a.status','=',1];
if(!empty($input['coach_id'])){
$dis[] = ['d.id','=',$input['coach_id']];
}
if(!empty($input['coach_name'])){
$dis[] = ['d.coach_name','like','%'.$input['coach_name'].'%'];
}
if(!empty($input['goods_name'])){
$dis[] = ['c.goods_name','like','%'.$input['goods_name'].'%'];
}
$comment_model = new Comment();
$data = $comment_model->dataList($dis);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
}
}
return $this->success($data);
}
}

View File

@@ -0,0 +1,270 @@
<?php
namespace app\massage\controller;
use app\ApiRest;
use app\massage\model\BalanceCard;
use app\massage\model\BalanceOrder;
use app\massage\model\BalanceWater;
use app\massage\model\Coach;
use app\massage\model\User;
use app\member\model\Level;
use app\Rest;
use think\App;
use think\Request;
class IndexBalance extends ApiRest
{
protected $model;
protected $article_model;
protected $coach_model;
protected $water_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new BalanceCard();
$this->balance_order = new BalanceOrder();
$this->water_model = new BalanceWater();
}
/**
* @author chenniang
* @DataTime: 2021-07-04 19:09
* @功能说明:储值充值卡列表
*/
public function cardList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',1];
if(!empty($input['name'])){
$dis[] = ['title','like','%'.$input['name'].'%'];
}
$data = $this->model->dataList($dis,$input['limit']);
if(!empty($data['data'])){
$level = new Level();
foreach ($data['data'] as &$v){
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
$v['member_title']= $level->where(['id'=>$v['member_level']])->value('title');
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-07 17:00
* @功能说明:充值余额
*/
public function payBalanceOrder(){
$input = $this->_input;
if(!empty($input['card_id'])){
$dis = [
'id' => $input['card_id'],
'status' => 1
];
$card = $this->model->dataInfo($dis);
if(empty($card)){
$this->errorMsg('充值卡已被下架');
}
}else{
$card = [
'price' => $input['price'],
'true_price' => $input['price'],
'id' => 0,
'member_level'=> 0,
'title' => '自定义金额充值'
];
}
$user_model = new User();
$level_model= new Level();
$user = $user_model->dataInfo(['id'=>$this->getUserId()]);
$user_level_discount = $level_model->where(['id'=>$user['member_level']])->value('discount');
$user_level_discount = !empty($user_level_discount)?$user_level_discount:0;
$member_level_dicount= $level_model->where(['id'=>$card['member_level']])->value('discount');
$member_level_dicount= !empty($member_level_dicount)?$member_level_dicount:0;
$card['member_level']= $member_level_dicount>$user_level_discount?$card['member_level']:0;
$insert = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'order_code' => orderCode(),
'pay_price' => $card['price'],
'sale_price' => $card['price'],
'true_price' => $card['true_price'],
'card_id' => $card['id'],
'title' => $card['title'],
'member_level'=> $card['member_level'],
'phone' => $input['phone']
];
$res = $this->balance_order->dataAdd($insert);
if($res==0){
$this->errorMsg('充值失败');
}
//微信支付
$pay_controller = new IndexWxPay($this->app);
//支付
$jsApiParameters= $pay_controller->createWeixinPay($this->payConfig(),$this->getUserInfo()['openid'],$this->_uniacid,"储值",['type' => 'Balance' , 'out_trade_no' => $insert['order_code']],$insert['pay_price']);
$arr['pay_list']= $jsApiParameters;
return $this->success($arr);
}
/**
* @author chenniang
* @DataTime: 2021-07-07 17:34
* @功能说明:充值订单列表
*/
public function balaceOrder(){
$input = $this->_param;
$dis[] = ['status','=',2];
$dis[] = ['user_id','=',$this->getUserId()];
if(!empty($input['start_time'])){
$dis[] = ['pay_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$data = $this->balance_order->dataList($dis);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
$v['pay_time'] = date('Y-m-d H:i:s',$v['pay_time']);
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-07 18:00
* @功能说明:消费明细
*/
public function payWater(){
$input = $this->_param;
$dis[] = ['user_id','=',$this->getUserId()];
// $dis[] = ['type','=',2];
if(!empty($input['start_time'])){
$dis[] = ['create_time','between',"{$input['start_time']},{$input['end_time']}"];
}
$data = $this->water_model->dataList($dis);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
}
}
return $this->success($data);
}
}

View File

@@ -0,0 +1,580 @@
<?php
namespace app\massage\controller;
use app\ApiRest;
use app\massage\model\BalanceWater;
use app\massage\model\Coach;
use app\massage\model\Config;
use app\massage\model\Goods;
use app\massage\model\Order;
use app\massage\model\Police;
use app\massage\model\RefundOrder;
use app\massage\model\RefundOrderGoods;
use app\massage\model\User;
use app\massage\model\Wallet;
use longbingcore\wxcore\WxSetting;
use think\App;
use think\facade\Db;
use think\Request;
class IndexCoach extends ApiRest
{
protected $model;
protected $cap_info;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Coach();
$this->order_model = new Order();
$cap_dis[] = ['user_id','=',$this->getUserId()];
$cap_dis[] = ['status','in',[2,3]];
$this->cap_info = $this->model->dataInfo($cap_dis);
if(empty($this->cap_info)){
$this->errorMsg('你还不是技师');
}
}
/**
* @author chenniang
* @DataTime: 2021-07-08 11:39
* @功能说明:技师首页
*/
public function coachIndex(){
$data = $this->cap_info;
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-23 09:59
* @功能说明:修改技师信息
*/
public function coachUpdate(){
$input = $this->_input;
$dis = [
'id' => $this->cap_info['id']
];
if(!empty($input['id_card'])){
$input['id_card'] = implode(',',$input['id_card']);
}
if(!empty($input['license'])){
$input['license'] = implode(',',$input['license']);
}
if(!empty($input['self_img'])){
$input['self_img'] = implode(',',$input['self_img']);
}
$res = $this->model->dataUpdate($dis,$input);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 15:48
* @功能说明:个人中心
*/
public function index(){
$data = $this->getUserInfo();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 15:48
* @功能说明:个人中心
*/
public function orderList(){
$input = $this->_param;
$dis[] = ['a.uniacid','=',$this->_uniacid];
$dis[] = ['a.coach_id','=',$this->cap_info['id']];
$where = [];
if(!empty($input['name'])){
$where[] = ['b.goods_name','like','%'.$input['name'].'%'];
$where[] = ['a.order_code','like','%'.$input['name'].'%'];
}
if($input['pay_type']==5){
$dis[] = ['a.pay_type','in',[3,4,5]];
}else{
$dis[] = ['a.pay_type','=',$input['pay_type']];
}
$order_model = new Order();
$data = $order_model->indexDataList($dis,$where);
//待接单数量
$data['agent_order_count'] = $order_model->where(['coach_id'=>$this->cap_info['id'],'pay_type'=>2])->count();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-07 23:11
* @功能说明:订单详情
*/
public function orderInfo(){
$input = $this->_param;
$dis = [
'id' => $input['order_id']
];
$data = $this->order_model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 13:33
* @功能说明:团长审核提现
*/
public function applyWallet(){
$input = $this->_input;
if(empty($input['apply_price'])||$input['apply_price']<0.01){
$this->errorMsg('提现费最低一分');
}
//服务费
if($input['apply_price']>$this->cap_info['service_price']&&$input['type']==1){
$this->errorMsg('余额不足');
}
//车费
if($input['apply_price']>$this->cap_info['car_price']&&$input['type']==2){
$this->errorMsg('余额不足');
}
$coach_level = $this->model->getCoachLevel($this->cap_info['id'],$this->_uniacid);
// dump($coach_level);exit;
//车费没有服务费
$balance = !empty($coach_level)&&$input['type']==1?$coach_level['balance']:100;
$key = 'cap_wallet'.$this->getUserId();
$value = getCache($key);
if(!empty($value)){
$this->errorMsg('网络错误,请刷新重试');
}
//加一个锁防止重复提交
incCache($key,1,$this->_uniacid);
Db::startTrans();
if($input['type']==1){
//减佣金
$res = $this->model->dataUpdate(['id'=>$this->cap_info['id']],['service_price'=>$this->cap_info['service_price']-$input['apply_price']]);
}else{
$res = $this->model->dataUpdate(['id'=>$this->cap_info['id']],['car_price'=>$this->cap_info['car_price']-$input['apply_price']]);
}
if($res!=1){
Db::rollback();
//减掉
delCache($key,$this->_uniacid);
$this->errorMsg('申请失败');
}
$insert = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'coach_id' => $this->cap_info['id'],
'total_price' => $input['apply_price'],
'balance' => $balance,
'apply_price' => round($input['apply_price']*$balance/100,2),
'service_price' => round($input['apply_price']-$input['apply_price']*$balance/100,2),
'code' => orderCode(),
'text' => $input['text'],
'type' => $input['type'],
];
$wallet_model = new Wallet();
//提交审核
$res = $wallet_model->dataAdd($insert);
if($res!=1){
Db::rollback();
//减掉
delCache($key,$this->_uniacid);
$this->errorMsg('申请失败');
}
Db::commit();
//减掉
delCache($key,$this->_uniacid);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-25 17:14
* @功能说明:楼长核销订单
*/
public function hxOrder(){
$input = $this->_input;
$order_model= new Order();
$order = $order_model->dataInfo(['id'=>$input['id']]);
if(empty($order)){
$this->errorMsg('订单未找到');
}
if($order['pay_type']!=5){
$this->errorMsg('订单状态错误');
}
if($order['coach_id']!=$this->cap_info['id']){
$this->errorMsg('你不是该订单的楼长');
}
$refund_model = new RefundOrder();
//判断有无申请中的退款订单
$refund_order = $refund_model->dataInfo(['order_id'=>$order['id'],'status'=>1]);
if(!empty($refund_order)){
$this->errorMsg('该订单正在申请退款,请先处理再核销');
}
$res = $order_model->hxOrder($order,$this->cap_info['id']);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-30 13:38
* @功能说明:团长端佣金信息
*/
public function capCashInfo(){
$this->order_model->coachBalanceArr($this->_uniacid);
$key = 'cap_wallet'.$this->getUserId();
//减掉
delCache($key,$this->_uniacid);
$wallet_model = new Wallet();
//可提现佣金
$data['cap_cash'] = $this->cap_info['service_price'];
//累计提现
$data['extract_total_price'] = $wallet_model->capCash($this->cap_info['id'],2,1);
//提现中
$data['extract_ing_price'] = $wallet_model->capCash($this->cap_info['id'],1,1);
$dis = [
'pay_type' => 7,
'coach_id' => $this->cap_info['id'],
'have_tx' => 0
];
//未到账
$data['no_received'] = $this->order_model->where($dis)->sum('service_price');
$data['coach_level'] = $this->model->getCoachLevel($this->cap_info['id'],$this->_uniacid);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-30 13:38
* @功能说明:团长端佣金信息
*/
public function capCashInfoCar(){
$key = 'cap_wallet'.$this->getUserId();
//减掉
delCache($key,$this->_uniacid);
$wallet_model = new Wallet();
//可提现佣金
$data['cap_cash'] = $this->cap_info['car_price'];
//累计提现
$data['extract_total_price'] = $wallet_model->capCash($this->cap_info['id'],2,2);
//提现中
$data['extract_ing_price'] = $wallet_model->capCash($this->cap_info['id'],1,2);
$dis = [
'pay_type' => 7,
'coach_id' => $this->cap_info['id'],
'have_tx' => 0
];
//未到账
$data['no_received'] = $this->order_model->where($dis)->sum('car_price');
$data['coach_level'] = $this->model->getCoachLevel($this->cap_info['id'],$this->_uniacid);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-30 14:39
* @功能说明:团长提现记录
*/
public function capCashList(){
$wallet_model = new Wallet();
$input = $this->_param;
$dis = [
'coach_id' => $this->cap_info['id']
];
if(!empty($input['status'])){
$dis['status'] = $input['status'];
}
$dis['type'] = $input['type'];
//提现记录
$data = $wallet_model->dataList($dis,10);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
}
}
//累计提现
$data['extract_total_price'] = $wallet_model->capCash($this->cap_info['id'],2,$input['type']);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-07-08 17:09
* @功能说明:报警
*/
public function police(){
$insert = [
'uniacid' => $this->_uniacid,
'coach_id'=> $this->cap_info['id'],
'user_id' => $this->cap_info['user_id'],
'text' => '正在发出求救信号,请及时查看技师正在服务的订单地址和电话,确认报警信息'
];
$police_model = new Police();
$res = $police_model->dataAdd($insert);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-07-11 22:34
* @功能说明:技师修改订单信息)
*/
public function updateOrder(){
$input = $this->_input;
$order = $this->order_model->dataInfo(['id'=>$input['order_id']]);
$update = $this->order_model->coachOrdertext($input);
Db::startTrans();
//核销订单
if($input['type']==7){
if($order['pay_type']!=6){
$this->errorMsg('订单状态错误');
}
$refund_model = new RefundOrder();
//判断有无申请中的退款订单
$refund_order = $refund_model->dataInfo(['order_id'=>$order['id'],'status'=>1]);
if(!empty($refund_order)){
$this->errorMsg('该订单正在申请退款,请先处理再核销');
}
$res = $this->order_model->hxOrder($order,$this->cap_info['id']);
$res = $this->order_model->dataUpdate(['id'=>$input['order_id']],$update);
}else{
// dump($update);exit;
$res = $this->order_model->dataUpdate(['id'=>$input['order_id']],$update);
//拒绝接单
if($input['type']==-1){
if($order['pay_type']!=2){
Db::rollback();
$this->errorMsg('已接单');
}
if($order['pay_price']>0){
$refund_model = new RefundOrder();
$res = $refund_model->refundCash($this->payConfig(),$order,$order['pay_price']);
if(!empty($res['code'])){
Db::rollback();
$this->errorMsg($res['msg']);
}
if($res!=true){
Db::rollback();
$this->errorMsg('退款失败请重试2');
}
}
}
}
Db::commit();
return $this->success($res);
}
}

View File

@@ -0,0 +1,308 @@
<?php
namespace app\massage\controller;
use app\ApiRest;
use app\Rest;
use app\massage\model\Cap;
use app\massage\model\Car;
use app\massage\model\Goods;
use app\massage\model\GoodsCate;
use app\massage\model\User;
use think\App;
use think\Request;
class IndexGoods extends ApiRest
{
protected $model;
protected $cate_model;
protected $car_model;
public function __construct(App $app) {
parent::__construct($app);
$this->model = new Goods();
// $this->cate_model = new GoodsCate();
$this->car_model = new Car();
}
/**
* @author chenniang
* @DataTime: 2021-03-18 16:46
* @功能说明:分类列表
*/
public function cateList(){
$input = $this->_param;
$dis = [
'uniacid' => $this->_uniacid,
'status' => 1,
'cap_id' => $this->getCapInfo()['id']
];
$data = $this->cate_model->where($dis)->order('id desc')->select()->toArray();
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:19
* @功能说明:商品列表
*/
public function goodsList(){
$input = $this->_param;
$dis = [
'uniacid' => $this->_uniacid,
'status' => 1,
];
//商品信息
$data = $this->model->dataList($dis,10);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:07
* @功能说明:购物车信息
*/
public function carInfo(){
//购物车信息
$car_info = $this->car_model->carPriceAndCount($this->getUserId(),$this->getCapInfo()['id'],1);
return $this->success($car_info);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 15:46
* @功能说明:商品详情
*/
public function goodsInfo(){
$input = $this->_param;
$dis = [
'id' => $input['id']
];
$data = $this->model->dataInfo($dis);
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 11:57
* @功能说明:首页选择楼长列表
*/
public function indexCapList(){
$input = $this->_param;
$dis[] = ['uniacid','=',$this->_uniacid];
$dis[] = ['status','=',2];
$dis[] = ['business_status','=',1];
if(!empty($input['store_name'])){
$dis[] = ['store_name','like','%'.$input['store_name'].'%'];
}
$lat = !empty($input['lat'])?$input['lat']:0;
$lng = !empty($input['lng'])?$input['lng']:0;
$alh = '(2 * 6378.137* ASIN(SQRT(POW(SIN(3.1415926535898*('.$lat.'-lat)/360),2)+COS(3.1415926535898*'.$lat.'/180)* COS('.$lat.' * 3.1415926535898/180)*POW(SIN(3.1415926535898*('.$lng.'-lng)/360),2))))*1000 as distance';
$alhs = '(2 * 6378.137* ASIN(SQRT(POW(SIN(3.1415926535898*('.$lat.'-lat)/360),2)+COS(3.1415926535898*'.$lat.'/180)* COS('.$lat.' * 3.1415926535898/180)*POW(SIN(3.1415926535898*('.$lng.'-lng)/360),2))))*1000<20000';
$cap_model = new Cap();
$data = $cap_model->dataList($dis,$alh,$alhs,10);
if(!empty($data['data'])){
foreach ($data['data'] as &$v){
$v['distance'] = getDistances($v['lng'],$v['lat'],$lng,$lat);
$v['distance'] = $cap_model->getDistanceAttr($v['distance']);
}
}
return $this->success($data);
}
/**
* @author chenniang
* @DataTime: 2021-03-19 13:24
* @功能说明:选择楼长
*/
public function selectCap(){
$input = $this->_input;
$user_model = new User();
$res = $user_model->dataUpdate(['id'=>$this->getUserId()],['cap_id'=>$input['cap_id']]);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:46
* @功能说明:添加到购物车
*/
public function addCar(){
$input = $this->_input;
$insert = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'cap_id' => $this->getCapInfo()['id'],
'goods_id'=> $input['goods_id'],
'spe_id' => $input['spe_id']
];
$info = $this->car_model->dataInfo($insert);
//增加数量
if(!empty($info)){
$res = $this->car_model->dataUpdate(['id'=>$info['id']],['goods_num'=>$info['goods_num']+$input['goods_num']]);
}else{
//添加到购物车
$insert['goods_num'] = $input['goods_num'];
$insert['status'] = 1;
$res = $this->car_model->dataAdd($insert);
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:54
* @功能说明:删除购物车
*/
public function delCar(){
$input = $this->_input;
$info = $this->car_model->dataInfo(['id'=>$input['id']]);
//加少数量
if($info['goods_num']>$input['goods_num']){
$res = $this->car_model->dataUpdate(['id'=>$info['id']],['goods_num'=>$info['goods_num']-$input['goods_num']]);
}else{
$res = $this->car_model->where(['id'=>$info['id']])->delete();
}
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-25 10:39
* @功能说明:
*/
public function carUpdate(){
$input = $this->_input;
$res = $this->car_model->where('id','in',$input['id'])->update(['status'=>$input['status']]);
return $this->success($res);
}
/**
* @author chenniang
* @DataTime: 2021-03-24 14:59
* @功能说明:批量删除购物车
*/
public function delSomeCar(){
$input = $this->_input;
$dis = [
'uniacid' => $this->_uniacid,
'user_id' => $this->getUserId(),
'cap_id' => $this->getCapInfo()['id'],
];
$res = $this->car_model->where($dis)->delete();
return $this->success($res);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,181 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use app\ApiRest;
use think\App;
use app\shop\controller\IndexPayResunt;
use think\facade\Db;
class IndexWxPay extends ApiRest
{
protected $app;
public function __construct ( App $app )
{
$this->app = $app;
}
/**
* @param $paymentApp
* @param $openid
* @param $uniacid
* @param $body
* @param $attach
* @param $totalprice
* @throws \WxPayException
* 支付
*/
public function createWeixinPay($paymentApp , $openid , $uniacid , $body , $attach,$totalprice){
global $_GPC, $_W;
$setting['mini_appid'] = $paymentApp['app_id'];
$setting['mini_appsecrept'] = $paymentApp['secret'];
$setting['mini_mid'] = $paymentApp['payment']['merchant_id'];
$setting['mini_apicode'] = $paymentApp['payment']['key'];
$setting['apiclient_cert'] = $paymentApp['payment']['cert_path'];
$setting['apiclient_cert_key'] = $paymentApp['payment']['key_path'];
define('WX_APPID', $setting['mini_appid']);
define('WX_MCHID', $setting['mini_mid']);
define('WX_KEY', $setting['mini_apicode']);
define('WX_APPSECRET', $setting['mini_appsecrept']);
define('WX_SSLCERT_PATH', $setting['apiclient_cert']);
define('WX_SSLKEY_PATH', $setting['apiclient_cert_key']);
define('WX_CURL_PROXY_HOST', '0.0.0.0');
define('WX_CURL_PROXY_PORT', 0);
define('WX_REPORT_LEVENL', 0);
require_once PAY_PATH . "/weixinpay/lib/WxPay.Api.php";
require_once PAY_PATH . "/weixinpay/example/WxPay.JsApiPay.php";
$tools = new \JsApiPay();
$input = new \WxPayUnifiedOrder();
$input->SetBody($body);
$input->SetAttach(json_encode($attach));
$input->SetOut_trade_no($attach['out_trade_no']);
$input->SetTotal_fee($totalprice *100);
$input->SetTime_start(date("YmdHis"));
$param_arr=[
'i' => $uniacid,
't' => $_GPC['t'],
'v' => $_GPC['v'],
'n' => APP_MODEL_NAME
];
$reply_path=json_encode($param_arr);
//需要判断 是否是微擎的版本
if(defined('IS_WEIQIN')){
$path = "https://" . $_SERVER['HTTP_HOST'] ."/addons/".APP_MODEL_NAME."/core2/app/Common/wexinPay.php?params=".$reply_path;
$paths = "https://" . $_SERVER['HTTP_HOST'] ."/addons/".APP_MODEL_NAME."/core2/app/Common/wexinPay.php?ck=789";
$a = file_get_contents($paths);
if($a != 1){
$this->errorMsg('发起支付失败');
}
}else{
$path = "https://" . $_SERVER['HTTP_HOST'] ."/wexinPay.php?params=".$reply_path;
$paths = "https://" . $_SERVER['HTTP_HOST'] ."/wexinPay.php?ck=789";
$a = file_get_contents($paths);
if($a != 1){
$this->errorMsg('发起支付失败');
}
}
$this ->lb_logOutput('BaseApiPath:-----'.$path);
$input->SetNotify_url($path);
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openid);
$order = \WxPayApi::unifiedOrder($input);
if(!empty($order['return_code'])&&$order['return_code'] == 'FAIL'){
$this->errorMsg($order['return_msg']);
}
$jsApiParameters = $tools->GetJsApiParameters($order);
$jsApiParameters = json_decode($jsApiParameters, true) ;
if (!empty($jsApiParameters['return_code']))
$this->errorMsg( '发起支付失败');
return $jsApiParameters;
}
/**
* @param $data
* @param int $flag
* @return void|null
* 打印数据
*/
public function lb_logOutput($data,$flag=0) {
if($flag==0){
return ;
}
//数据类型检测
if (is_array($data)) {
$data = json_encode($data);
}
$filename = "./".date("Y-m-d").".log";
$str = date("Y-m-d H:i:s")." $data"."\r\n";
file_put_contents($filename, $str, FILE_APPEND|LOCK_EX);
return null;
}
/**
* 支付回调
*/
public function returnPay(){
$this->lb_logOutput("in--mingpianNotify");
$xmlData = file_get_contents('php://input');
if(empty($xmlData)){
$xmlData = 'empty xmlData';
}
$this->lb_logOutput('xmlData in mingpian:-----'.$xmlData);
$this->lb_logOutput("in-mingpian2");
global $_GPC;
$xmlData = file_get_contents('php://input');
$this->lb_logOutput('in-mingpian-$xmlData:-----'.$xmlData);
//获取配置
if(defined( 'IS_WEIQIN' )){
$uniacid=$_GPC['i'];
}else{
$uniacid = $_GET['i'];
}
$paymentApp = $this->payConfig($uniacid);
// dump($paymentApp);exit;
$this->lb_logOutput('in-mingpian-uniacid:-----'.$uniacid);
$setting['mini_appid'] = $paymentApp['app_id'];
$setting['mini_appsecrept'] = $paymentApp['secret'];
$setting['mini_mid'] = $paymentApp['payment']['merchant_id'];
$setting['mini_apicode'] = $paymentApp['payment']['key'];
$setting['apiclient_cert'] = $paymentApp['payment']['cert_path'];
$setting['apiclient_cert_key'] = $paymentApp['payment']['key_path'];
define('WX_APPID', $setting['mini_appid']);
define('WX_MCHID', $setting['mini_mid']);
define('WX_KEY', $setting['mini_apicode']);
define('WX_APPSECRET', $setting['mini_appsecrept']);
define('WX_SSLCERT_PATH', $setting['apiclient_cert']);
define('WX_SSLKEY_PATH', $setting['apiclient_cert_key']);
define('WX_CURL_PROXY_HOST', '0.0.0.0');
define('WX_CURL_PROXY_PORT', 0);
define('WX_REPORT_LEVENL', 0);
require_once PAY_PATH.'/weixinpay/lib/WxOrderNotify.php';
$WxPay = new \WxOrderNotify($this->app);
$WxPay->Handle(false);
}
}

View File

@@ -0,0 +1,275 @@
<?php
namespace app\massage\controller;
use app\AdminRest;
use app\BaseController;
use app\massage\model\Service;
use app\shop\model\Article;
use app\shop\model\Banner;
use app\shop\model\Cap;
use app\shop\model\GoodsCate;
use app\shop\model\GoodsSh;
use app\shop\model\GoodsShList;
use think\App;
use app\shop\model\Goods as Model;
use think\Db;
use think\facade\View;
class Tcp extends BaseController
{
protected $model;
protected $goods_sh;
protected $goods_sh_list;
public function __construct(App $app) {
parent::__construct($app);
// $this->model = new Service();
}
/**
* @author chenniang
* @DataTime: 2021-09-29 16:25
* @功能说明:远程获取信息
*/
public function getInfo(){
//获取param
$input= $this->request->param();
if(!empty($input['card_id'])&&!empty($input['time'])){
$info = \think\facade\Db::name('shequshop_car_atv_speed_test')->where(['card_id'=>$input['card_id']])->find();
$insert = [
'card_id' => $input['card_id'],
'time' => date('Y-m-d H:i:s',time()),
'uniacid' => 1,
'time_str'=> time()
];
if(empty($info)){
\think\facade\Db::name('shequshop_car_atv_speed_test')->insert($insert);
}else{
\think\facade\Db::name('shequshop_car_atv_speed_test')->where(['id'=>$info['id']])->update($insert);
//如果两次信号间隔时间小于30秒 不记录
if(time()-$info['time_str']<30){
echo 2;exit;
}
}
}else{
echo true;exit;
}
$card_id = $input['card_id'];
$dis = [
'now_card_id' => $card_id
];
$game = \think\facade\Db::name('shequshop_car_game')->where($dis)->find();
//当前绑卡的比赛
if(!empty($game)){
$dis = [
'record_id' => $game['id'],
'end_time' => 0
];
//查看是开始还是结束
$is_start = \think\facade\Db::name('shequshop_car_atv_speed')->where($dis)->find();
$c_time = time()-$game['last_time'];
//如果两个信号接受时间未超过40秒 不记录信息
if($c_time<30){
echo false;exit;
}
//开始
if(empty($is_start)){
$insert = [
'uniacid' => $game['uniacid'],
'record_id' => $game['id'],
'user_id' => $game['user_id'],
'start_time' => $input['time'],
];
\think\facade\Db::name('shequshop_car_atv_speed')->insert($insert);
}else{
// //如果两个信号接受时间未超过40秒 不记录信息
// if($c_time<40){
//
// echo false;exit;
// }
$time = $input['time'] - $is_start['start_time'];
//结束
$update = [
'end_time' => $input['time'],
'time' => $time,
];
\think\facade\Db::name('shequshop_car_atv_speed')->where(['id'=>$is_start['id']])->update($update);
if($time<$game['best_time']||$game['best_time']==0){
$update_game = [
'best_time' => $time
];
}
$total_time = $game['total_time']+$time;
$game['have_num']++;
$update_game['total_time'] = $total_time;
$update_game['have_game'] = 1;
$update_game['status'] = 2;
$update_game['have_num'] = $game['have_num'];
//修改最好成绩
\think\facade\Db::name('shequshop_car_game')->where(['id'=>$game['id']])->update($update_game);
//第二圈开始
$insert = [
'uniacid' => $game['uniacid'],
'record_id' => $game['id'],
'user_id' => $game['user_id'],
'start_time' => $input['time'],
];
\think\facade\Db::name('shequshop_car_atv_speed')->insert($insert);
}
$update = [
'last_time' => intval($input['time']/1000),
];
if(empty($game['start_time'])){
$update['start_time'] = intval($input['time']/1000);
$update['day'] = date('Y-m-d',time());
}
//修改最后接受信息时间
\think\facade\Db::name('shequshop_car_game')->where(['id'=>$game['id']])->update($update);
}
echo true;exit;
}
/**
* @author chenniang
* @DataTime: 2021-10-28 14:53
* @功能说明:
*/
public function gameList(){
$dis = [
'uniacid' => 1,
'have_game' => 1
];
$data = \think\facade\Db::name('shequshop_car_game')->where($dis)->field('best_time,start_time,user_id')->order('start_time desc,best_time')->limit(50)->select()->toArray();
if(!empty($data)){
foreach ($data as &$v){
$v['user_name'] = \think\facade\Db::name('massage_service_user_list')->where(['id'=>$v['user_id']])->value('nickName');
$v['start_time'] = date('m-d H:i:s',$v['start_time']);
$v['best_time'] = game_time($v['best_time']);
}
}
$count = count($data);
View::assign('data', $data);
View::assign('count', $count);
return View::fetch();
echo json_encode($datas);exit;
}
}