100 行
3.4 KiB
PHP
可执行文件
100 行
3.4 KiB
PHP
可执行文件
<?php
|
||
/**
|
||
* Created by PhpStorm.
|
||
* User: yang
|
||
* Date: 2021/3/30
|
||
* Time: 15:10
|
||
*/
|
||
|
||
namespace Blessing\Controller;
|
||
|
||
use Retail\Controller\BaseController;
|
||
use Blessing\Business\Index;
|
||
use Blessing\Model\BlessingModel;
|
||
use Common\Business\Plug;
|
||
|
||
use Common\Model\RetailStoreModel;
|
||
use Common\Model\RetailPlugModel;
|
||
use Common\Model\RetailPlugStoreModel;
|
||
use Common\Model\RetailManagerModel;
|
||
use Think\Controller;
|
||
use Common\Validate\CustomValidate;
|
||
|
||
//游客
|
||
class TouristController extends Controller{
|
||
|
||
//页面
|
||
public function index(){
|
||
$this->display();
|
||
}
|
||
|
||
/**
|
||
* 祝福语
|
||
*/
|
||
//查询祝福语(post)
|
||
public function blessingList(){
|
||
$post = I("post.");
|
||
$param = [
|
||
'storeId',//门店id
|
||
'extractionCode',//提取码
|
||
];
|
||
$index = new Index();
|
||
$customValidate = new CustomValidate();
|
||
$dataOne = $customValidate->validationParameters($param,$post);
|
||
if($dataOne !== true){
|
||
$this->ajaxReturn($dataOne);
|
||
}
|
||
if($post['extractionCode'] == '' || $post['storeId'] == ''){
|
||
$res = callBack(statusCode()['error'],'请输入祝福码');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
$where = [
|
||
'store_id'=>$post['storeId'],//门店id
|
||
'extraction_code'=>$post['extractionCode'],//提取码
|
||
];
|
||
$field = [
|
||
'type',//类型:1视频,2音频
|
||
'storage_type',//存储类型:1本地,2七牛云,3腾讯云,4阿里云
|
||
'address',//路径地址
|
||
'validity_time',//1永久有效,有效期:时间戳
|
||
'url',//路径
|
||
];
|
||
$plugBlessingModel = new BlessingModel();
|
||
$data = $plugBlessingModel->getFind($where,$field);
|
||
if(!$data){
|
||
$res = callBack(statusCode()['error'],'祝福码错误');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
//判断祝福语是否过期
|
||
$time = time();
|
||
if($data['validity_time'] && $data['validity_time'] != 1 && $data['validity_time'] < $time){
|
||
$res = callBack(statusCode()['error'],'祝福语已过期');
|
||
$this->ajaxReturn($res);
|
||
}
|
||
if($data === false){
|
||
$res = callBack(statusCode()['error'],'失败');
|
||
}else{
|
||
if($data && $data['storage_type'] == 1){
|
||
$entrance_style = getServerUrl();
|
||
$data['address'] = $entrance_style.'/'.$data['url'];
|
||
}
|
||
//合伙人设置
|
||
$identification = 'blessing';//插件标识
|
||
$limitSize = $index->plugSetInfo($identification);
|
||
$data['duration_type'] = $limitSize['duration_type'];//1永久时长 2固定时长
|
||
$data['duration_time'] = $limitSize['duration_time'];//固定的时长
|
||
$data['duration_start_type'] = $limitSize['duration_start_type'];//开始计时的时候 1确认收货后 2首次扫码后
|
||
if(!$data['validity_time']){
|
||
//没有有效期,第一次,修改有效期
|
||
$validity_time = $index->validityTimeSave($post['storeId'],1,$post['extractionCode']);//修改有效期:$type == 1:首次扫码(id = 门店id),2:确认订单(id = 订单id)
|
||
if($validity_time !== false){
|
||
$data['validity_time'] = $validity_time;
|
||
}
|
||
}
|
||
$res = callBack(statusCode()['success'],'成功',$data);
|
||
}
|
||
$this->ajaxReturn($res);
|
||
}
|
||
|
||
|
||
} |