|
|
<?php
|
|
|
|
|
|
namespace app\api\controller\v1;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
use think\Db;
|
|
|
use think\Exception;
|
|
|
|
|
|
/**
|
|
|
* 用户端接口
|
|
|
*/
|
|
|
class Client extends Api
|
|
|
{
|
|
|
protected $noNeedLogin = ['*'];
|
|
|
protected $noNeedRight = ['*'];
|
|
|
protected $postParam;
|
|
|
protected $store_id;
|
|
|
protected $store;
|
|
|
|
|
|
public function _initialize()
|
|
|
{
|
|
|
$postParam = $this->request->param();
|
|
|
$this->postParam = $postParam;
|
|
|
|
|
|
parent::_initialize();
|
|
|
$this->auth->id = 1;//测试用
|
|
|
$postParam = $this->request->param();
|
|
|
$this->postParam = $postParam;
|
|
|
if (empty($postParam['code'])) {
|
|
|
$this->error("门店code异常");
|
|
|
}
|
|
|
$this->store_id = $postParam['code'];
|
|
|
$store = Db::name("verification_store")->where("id", $this->store_id)->find();
|
|
|
if (empty($store)) {
|
|
|
$this->error("门店不存在,请退出登录后重试!");
|
|
|
}
|
|
|
$this->store = $store;
|
|
|
if (empty($this->auth->id)) {
|
|
|
$this->error("暂无权限!");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
/**
|
|
|
* 1、获取活动
|
|
|
*/
|
|
|
public function getactivity(){
|
|
|
//根据门店查询活动
|
|
|
$time=time();
|
|
|
$where["closetime"] = [">", $time];
|
|
|
$where["verification_store_id"] = ["=", $this->store_id];
|
|
|
$activity=Db::name('verification_activity')->where($where)->find();
|
|
|
$this->success('活动获取成功', $activity);
|
|
|
}
|
|
|
/**
|
|
|
* 1.1参加活动用户信息
|
|
|
*/
|
|
|
public function participate_activitie(){
|
|
|
$activity_id=$this->postParam['id'];
|
|
|
$page = $this->request->post('page', 1);
|
|
|
$total = $this->request->post('total', 10);
|
|
|
$where['type']=1;
|
|
|
$where['verification_activity_id']=$activity_id;
|
|
|
|
|
|
$user=Db::name("verification_order")
|
|
|
->where('verification_activity_id','=',$activity_id)
|
|
|
->field('name')
|
|
|
->paginate($total, false, ['page' => $page])
|
|
|
->toArray();
|
|
|
if(!empty($user['data'])){
|
|
|
for ($i=0;$i<count($user['data']);$i++){
|
|
|
$sort=$i+1;
|
|
|
$user['data'][$i]['sort']=$sort;
|
|
|
$user['data'][$i]['name']=$this->substr_cut($user['data'][$i]['name']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$this->success('查询成功',$user);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 1.1.1名字加*
|
|
|
* @param $user_name
|
|
|
* @return string
|
|
|
*/
|
|
|
function substr_cut($user_name){
|
|
|
$strlen = mb_strlen($user_name, 'utf-8'); //获取字符长度
|
|
|
$firstStr = mb_substr($user_name, 0, 1, 'utf-8'); //查找字符第一个
|
|
|
$str=$firstStr . str_repeat('*', $strlen - 1); //拼接第一个+把字符串 "* " 重复 $strlen - 1 次:
|
|
|
return $str;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 2、举办活动
|
|
|
*/
|
|
|
public function holdactivity(){
|
|
|
$verification_store_id=$this->store_id;
|
|
|
$name=$this->postParam['name'];
|
|
|
$phone=$this->postParam['phone'];
|
|
|
$industry=$this->postParam['industry'];
|
|
|
$address=$this->postParam['address'];
|
|
|
$verification_activity_id=$this->postParam['id'];
|
|
|
$user_id=$this->auth->id;
|
|
|
$data=[
|
|
|
'verification_store_id'=>$verification_store_id,
|
|
|
'name'=>$name,
|
|
|
'phone'=>$phone,
|
|
|
'industry'=>$industry,
|
|
|
'address'=>$address,
|
|
|
'verification_activity_id'=>$verification_activity_id,
|
|
|
'user_id'=>$user_id
|
|
|
];
|
|
|
$res=Db::name('verification_hold_activity')->insertGetId($data);
|
|
|
if($res){
|
|
|
$this->success("提交成功");
|
|
|
}else{
|
|
|
$this->error("提交失败");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 3、查询个人订单
|
|
|
*/
|
|
|
public function myorder(){
|
|
|
$id=$this->auth->id;
|
|
|
$type=$this->postParam['type'];
|
|
|
$verification_store_id=$this->store_id;
|
|
|
$where['a.verification_store_id']=$verification_store_id;
|
|
|
$page = $this->request->post('page', 1);
|
|
|
$total = $this->request->post('total', 10);
|
|
|
|
|
|
if($type){
|
|
|
$where['a.type']=$type;
|
|
|
}
|
|
|
$row=Db::name('verification_order')
|
|
|
->alias('a')
|
|
|
->join('verification_store b','a.verification_store_id=b.id')
|
|
|
->where($where)
|
|
|
->paginate($total, false, ['page' => $page])
|
|
|
->toArray();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 4、订单详情
|
|
|
*/
|
|
|
public function orderinfo(){
|
|
|
$order_id=$this->postParam['id'];
|
|
|
$where['id']=$order_id;
|
|
|
$where['user_id']=$this->auth->id;
|
|
|
$order=Db::name('verification_order')->where($where)->find();
|
|
|
if($order){
|
|
|
$receivewhere['verification_order_id']=$order_id;
|
|
|
$receive=Db::name('cv_verification_receive')->where($receivewhere)->select();
|
|
|
$order['receive']=$receive;
|
|
|
$this->success("查询成功",$order);
|
|
|
}else{
|
|
|
$this->error("查询失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 5、卡卷详情
|
|
|
*/
|
|
|
public function receiveinfo(){
|
|
|
$receive=$this->postParam['id'];
|
|
|
$where['id']=$receive;
|
|
|
$where['user_id']=$this->auth->id;
|
|
|
$field="a.*,b.image,b.name";
|
|
|
$receive=Db::name('cv_verification_receive')
|
|
|
->alias('a')
|
|
|
->join('verification_store b','a.verification_store_id=b.id')
|
|
|
->where($where)
|
|
|
->field($field)
|
|
|
->find();
|
|
|
$this->success("查询成功",$receive);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|