Commit 0da9431f authored by 龚双喜's avatar 龚双喜

增加每月最新商品列表

parent f04132b3
......@@ -10,13 +10,15 @@ use app\common\library\Sms as Smslib;
use app\admin\model\shopro\user\User as UserModel;
use addons\shopro\facade\Wechat;
use app\common\model\shopro\Ad;
use think\Db;
use think\Hook;
use think\Log;
class Index extends Common
{
use Util;
protected $noNeedLogin = ['init', 'pageSync', 'page', 'feedback', 'send', 'test', 'ad'];
protected $noNeedLogin = ['init', 'pageSync', 'page', 'feedback', 'send', 'test', 'ad', 'monthlyNewGoods'];
protected $noNeedRight = ['*'];
public function init()
......@@ -200,6 +202,28 @@ class Index extends Common
/**
* 获取每月最新商品
* 每月取最新上架的商品,没有返回空
*/
public function monthlyNewGoods()
{
$limit = $this->request->param('limit', 10);
$month = $this->request->param('month', date('Y-m'));
$goods = \app\admin\model\shopro\goods\Goods::where('status', 'up')
->field('id,title,image,original_price,price')
->whereTime('createtime', 'between', ["{$month}-01", "{$month}-31"])
->order('createtime', 'desc')
->limit($limit)
->select();
if (!$goods) {
$this->success('获取成功', []);
}
$this->success('获取成功', $goods);
}
/**
* 获取统一验证 token
*
* @return void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment