dlh_test_server/app/api/logic/GroupBuyLogic.php

80 lines
2.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\api\logic;
use app\common\basics\Logic;
use app\common\model\groupbuy\GroupbuyGoods;
use app\common\server\UrlServer;
class GroupBuyLogic extends Logic
{
/**
* @param $get
* @return array
* 抢购商品列表
*/
public static function getGroupBuyGoods($get):array
{
$where = [
'gu.del'=>'1',
'gu.status'=> '1'
];
$field = 'gu.*,g.id as goods_id,g.name as goods_name,g.image as goods_image,g.min_price as goods_min_price';
//查询抢购商品
$lists = GroupbuyGoods::alias('gu')
->leftJoin('goods g', 'g.id=gu.goods_id')
->group('g.id')
->field($field)
->where($where)
->order("gu.activity_price asc")
->select()
->toArray();
//分页处理
$count = count($lists);
$index = ($get['page_no']-1) * $get['page_size'];
$lists = array_slice($lists, $index, $get['page_size']);
//处理列表数据
foreach($lists as &$item) {
// 图片加域名
$item['goods_image'] = UrlServer::getFileUrl($item['goods_image']);
}
$lists = [];
return [
'count' => $count,
'lists' => $lists,
'page_no' => $get['page_no'],
'page_size' => $get['page_size'],
'more' => is_more($count, $get['page_no'], $get['page_size']),
'rule'=>'抢购规则:<br/>
1、抢购活动时间:10月1号至10月7号;<br/>
2、抢购场次:活动期内每天上午12点及晚上8点各一场,抢完即止;<br/>
3、抢购权限:活动期间内每人及每个身份证只能抢购一次;<br/>
4、确认抢购成功条件:以付款成功为确认抢购成功;抢购成功后5分钟内不支付款项的,则视为放弃。<br/>
5、抢购活动产生的订单也参与平台消费返补活动;<br/>
6、所有抢购成功并支付款项的,对应抢购商品统一于节后全部发出,运费自付!<br/>
7、抢购商品,非质量问题,不接受退货!'
];
}
public static function isGroupbuy($item_id){
$where = [
'item_id'=>$item_id,
'status'=>1,
'del'=>1
];
$groupBuy = GroupbuyGoods::where($where)->find();
return $groupBuy;
}
}