You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
5.8 KiB

<?php
namespace app\task\controller;
use app\service\task\GoodsService;
use think\facade\Db;
class Goods extends Base
{
public function __construct()
{
parent::__construct();
$this->redis = new \Redis();
$this->redis->connect('127.0.0.1', 6379);
}
/**
* @title 通过委托系统查询委托数据信息
* @url /task/Goods/getApiGoods
* @method POST
* @param string page 用户名/手机号 / 是
* @param string limit 密码 / 是
* @return string msg 返回信息
* @return int code 状态码 200:成功;>=400:失败
*/
public function getApiGoods(){
try {
if($this->redis->get('getApiGoods') > 0){
return ;
}
$this->redis->set('getApiGoods', 1);
$goodsService = new GoodsService();
Db::startTrans();
$goodsService->getApiGoods();
Db::commit();
$this->redis->set('getApiGoods', 0);
return _success('成功');
}catch(\Exception $e){
Db::rollback();
$this->redis->set('getApiGoods', 0);
return _error($e->getMessage(), $e->getCode() ?: 400, $e);
}
}
/**
* @title 通过委托系统查询撤销委托数据信息
* @url /task/Goods/getRevocationGoods
* @method POST
* @param string page 用户名/手机号 / 是
* @param string limit 密码 / 是
* @return string msg 返回信息
* @return int code 状态码 200:成功;>=400:失败
*/
public function getRevocationGoods(){
try {
if($this->redis->get('getRevocationGoods') > 0){
return ;
}
$this->redis->set('getRevocationGoods', 1, 20);
$goodsService = new GoodsService();
Db::startTrans();
$goodsService->getRevocationGoods();
Db::commit();
$this->redis->set('getRevocationGoods', 0);
return _success('成功');
}catch(\Exception $e){
Db::rollback();
$this->redis->set('getRevocationGoods', 0);
return _error($e->getMessage(), $e->getCode() ?: 400, $e);
}
}
/**
* @title 查询撤销结果
* @url /task/Goods/getRevocationResult
* @method POST
* @param string page 用户名/手机号 / 是
* @param string limit 密码 / 是
* @return string msg 返回信息
* @return int code 状态码 200:成功;>=400:失败
*/
public function getRevocationResult(){
try {
if($this->redis->get('getRevocationResult') > 0){
// return ;
}
$this->redis->set('getRevocationResult', 1, 30);
$goodsService = new GoodsService();
Db::startTrans();
$goodsService->getRevocationResult();
Db::commit();
$this->redis->set('getRevocationResult', 0);
return _success('成功');
}catch(\Exception $e){
Db::rollback();
$this->redis->set('getRevocationResult', 0);
return _error($e->getMessage(), $e->getCode() ?: 400, $e);
}
}
/**
* @title 委托数据过期
* @url /task/Goods/getRevocationGoods
* @method POST
* @param string page 用户名/手机号 / 是
* @param string limit 密码 / 是
* @return string msg 返回信息
* @return int code 状态码 200:成功;>=400:失败
*/
public function goodsPast(){
try {
if($this->redis->get('goodsPast') > 0){
return ;
}
$this->redis->set('goodsPast', 1);
$goodsService = new GoodsService();
Db::startTrans();
$goodsService->goodsPast();
Db::commit();
$this->redis->set('goodsPast', 0);
return _success('成功');
}catch(\Exception $e){
Db::rollback();
$this->redis->set('goodsPast', 0);
return _error($e->getMessage(), $e->getCode() ?: 400, $e);
}
}
/**
* @title 委托数据上架时间开始上架
* @url /task/Goods/goodsDatePutaway
* @method POST
* @param string page 用户名/手机号 / 是
* @param string limit 密码 / 是
* @return string msg 返回信息
* @return int code 状态码 200:成功;>=400:失败
*/
public function goodsDatePutaway(){
try {
if($this->redis->get('goodsDatePutaway') > 0){
return ;
}
$this->redis->set('goodsDatePutaway', 1);
$goodsService = new GoodsService();
Db::startTrans();
$goodsService->goodsDatePutaway();
Db::commit();
$this->redis->set('goodsDatePutaway', 0);
return _success('成功');
}catch(\Exception $e){
Db::rollback();
$this->redis->set('goodsDatePutaway', 0);
return _error($e->getMessage(), $e->getCode() ?: 400, $e);
}
}
/**
* @title 委托数据拼接
* @url /task/Goods/goodsJoinField
* @method POST
* @return string msg 返回信息
* @return int code 状态码 200:成功;>=400:失败
*/
public function goodsJoinField(){
try {
if($this->redis->get('goodsJoinField') > 0){
// return ;
}
$this->redis->set('goodsJoinField', 1);
$goodsService = new GoodsService();
Db::startTrans();
$goodsService->goodsJoinField();
Db::commit();
$this->redis->set('goodsJoinField', 0);
return _success('成功');
}catch(\Exception $e){
Db::rollback();
$this->redis->set('goodsJoinField', 0);
return _error($e->getMessage(), $e->getCode() ?: 400, $e);
}
}
}