当前位置:网站首页>Zunpin Yongyao advertising e-commerce system -- Zunpin Yongyao advertising e-commerce app system development source code sharing
Zunpin Yongyao advertising e-commerce system -- Zunpin Yongyao advertising e-commerce app system development source code sharing
2022-06-25 12:27:00 【Procedure 15528175269】
Zunpin Yongyao advertising e-commerce system development source code sharing :
<?php
namespace app\api\controller\user;
use app\models\ad\AdSeeLog;
use app\models\ad\AdTask;
use app\models\ad\AdTaskLog;
use app\admin\model\ad\Video;
use app\Request;
use app\models\user\User;
use crmeb\services\UtilService;
/**
* Advertising task
* Class AdTaskController
* @package app\api\controller\user
*/
class AdTaskController
{
/**
* Receive advertising tasks
* @return mixed
*/
public function task(Request $request)
{
$uid = $request->uid();
list($id) = UtilService::postMore([
[['id', 'd'], 0],
], $request, true);
if (!$id || $id <= 0) return app('json')->fail(' Parameter error ');
$data = AdTask::where('id', $id)->find();
if (empty($data)) {
return app('json')->fail(' The task does not exist !');
}
$user = User::getUserInfo($uid);
if($user['buy_money'] < $data['min']){
return app('json')->fail(' Your purchase amount is not enough , You cannot claim this task !');
}
$count = AdTaskLog::where('uid', $uid)->where('task_id', $id)->count('*');
if($count){
return app('json')->fail(' You have received this task !');
}
$res = AdTask::setAdTask($uid, $data);
if ($res) {
return app('json')->success(' Claim success ');
} else {
return app('json')->fail(' Failed to collect ');
}
}
/**
* Ad task list
* @param Request $request
* @return mixed
*/
public function index(Request $request)
{
list($page, $limit) = UtilService::getMore([
['page', 0],
['limit', 0],
], $request, true);
return app('json')->successful(AdTask::getTaskList($request->uid(), $page, $limit));
}
// Get advertising data
public function getAd(Request $request){
$uid = $request->uid();
$user = User::getUserInfo($uid);
if($user['task_log_id'] == 0){
return app('json')->fail(' You didn't get the ad assignment , Please get it first ');
}
if($user['see_ad_count'] == 0){
return app('json')->fail(' You have run out of ads today , Please come back tomorrow ');
}
$time = date('Y-m-d', time());
$logList = AdSeeLog::where('uid', $uid)->whereDay('add_time', $time)->field('ad_id')->select();
if(empty($logList)){
$list = Video::where('status', 0)->orderRand()->limit(0,1)->select();
} else {
$listId = array_column($logList->toArray(),'ad_id');
$con = implode(",", $listId);
$list = Video::where('status', 0)->whereNotIn('id', $con)->orderRand()->limit(0,1)->select();
}
$list = $list->toArray();
if($list){
$ad = $list[0];
$str = substr($ad['file_add'], 0, 4);
if(!($str =='http')){
$ad['file_add'] = sys_config('site_url') . $ad['file_add'];
}
} else {
return app('json')->fail(' No advertising ');
}
$data['ad'] = $ad;
return app('json')->successful($data);
}
public function adCount(Request $request) {
$uid = $request->uid();
list($aid) = UtilService::postMore([
[['aid', 'd'], 0],
], $request, true);
$res = AdTask::adCount($uid, $aid);
if($res){
$user = User::getUserInfo($uid);
$data['msg'] = ' Successful advertising revenue ';
$data['see_ad_count'] = $user['see_ad_count'];
return app('json')->successful($data);
} else {
return app('json')->fail(' Advertising revenue acquisition failed , Please try again ');
}
}
}边栏推荐
- 2022 Baidu collection batch automatic push assistant
- flutter常用命令及问题
- Arm immediate
- Arm V7 LDR STR memory access
- 【数据中台】数据中台的OneID是个什么鬼,主数据它不香吗?
- Arm V7 continuous load / store
- Explain AHP in human language (very detailed principle + simple tool implementation)
- Dynamic proxy
- PD1.4转HDMI2.0转接线拆解。
- R语言caTools包进行数据划分、scale函数进行数据缩放、e1071包的naiveBayes函数构建朴素贝叶斯模型
猜你喜欢

19. Implementation of MVVM architecture based on WPF event to command

Découvrir gaussdb (pour redis): une comparaison complète avec Codis

一款好用的印章设计工具 --(可转为ofd文件)

2022 meisai topic C idea sharing + translation

使用php脚本查看已开启的扩展

黑马畅购商城---1.项目介绍-环境搭建

flutter常用命令及问题

黑马畅购商城---3.商品管理

Architects reveal the difference between working in Alibaba, Tencent and meituan
![[oceanbase] Introduction to oceanbase and its comparison with MySQL](/img/1c/bd2bcddb7af4647407d2bc351f5f5d.png)
[oceanbase] Introduction to oceanbase and its comparison with MySQL
随机推荐
实现领域驱动设计 - 使用ABP框架 - 系列文章汇总
R language uses GLM function to build Poisson logarithmic linear regression model, processes three-dimensional contingency table data to build saturation model, and poisgof function of epidisplay pack
sudo: ulimit: command not found
apple 为什么要改 objc_msgSend 的类型申明
JS monitors the width and height changes of div
Architects reveal the difference between working in Alibaba, Tencent and meituan
2022 meisai e topic ideas sharing + translation
VIM common commands and shortcut keys
R语言caTools包进行数据划分、scale函数进行数据缩放、e1071包的naiveBayes函数构建朴素贝叶斯模型
ARM V7 连续加载/存储
19. Implementation of MVVM architecture based on WPF event to command
Explain AHP in human language (very detailed principle + simple tool implementation)
plt. GCA () picture frame and label
Dark horse shopping mall ---1 Project introduction - environment construction
Mpai data science platform SVM support vector machine classification \ explanation of regression parameter adjustment
Kotlin Foundation
R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用summary函数获取模型汇总统计信息
confluence7.4. X upgrade record
一套自动化无纸办公系统(OA+审批流)源码:带数据字典
什么是Flink?Flink能用来做什么?