徐总多门店
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.

242 lines
7.0 KiB

2 months ago
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\api\v2\activity;
1 month ago
use app\controller\store\AuthController;
2 months ago
use app\services\activity\coupon\StoreCouponIssueServices;
use app\services\product\product\StoreProductCouponServices;
1 month ago
use think\facade\Db;
2 months ago
use think\Request;
/**
* 优惠券
* Class StoreCoupons
* @package app\controller\api\v2\store
*/
1 month ago
class StoreCoupons extends AuthController
2 months ago
{
protected $services;
public function __construct(StoreCouponIssueServices $services)
{
$this->services = $services;
}
/**
* 可领取优惠券列表
* @param \app\Request $request
* @return mixed
*/
public function lst(Request $request)
{
1 month ago
$where = $request->getMore([
[['type', 'd'], ''],
[['product_id', 'd'], 0],
[['brand_id', 'd'], 0],
['defaultOrder', ''],
['timeOrder', ''],
['priceOrder', '']
]);
return app('json')->successful($this->services->getIssueCouponList($request->uid(), $where, '*', true));
2 months ago
}
/**
* 获取新人券
* @return mixed
*/
public function getNewCoupon(Request $request)
{
$userInfo = $request->user();
$data = [];
/** @var StoreCouponIssueServices $couponService */
$couponService = app()->make(StoreCouponIssueServices::class);
$data['list'] = $couponService->getNewCoupon();
$data['image'] = '';
if ($userInfo->add_time === $userInfo->last_time) {
$data['show'] = 1;
} else {
$data['show'] = 0;
}
//会员领取优惠券
//$couponService->sendMemberCoupon($userInfo->uid);
return app('json')->success($data);
}
/**
* 赠送下单之后订单中 关联优惠劵
* @param Request $request
* @param $orderId
* @return mixed
*/
public function getOrderProductCoupon(Request $request, $orderId)
{
$uid = (int)$request->uid();
if (!$orderId) {
return app('json')->fail('参数错误');
}
/** @var StoreProductCouponServices $storeProductCoupon */
$storeProductCoupon = app()->make(StoreProductCouponServices::class);
$list = $storeProductCoupon->getOrderProductCoupon($uid, $orderId);
return app('json')->success($list);
}
/**
* 获取每日新增的优惠券
* @return mixed
*/
public function getTodayCoupon(Request $request)
{
$uid = 0;
if ($request->hasMacro('uid')) $uid = (int)$request->uid();
/** @var StoreCouponIssueServices $couponService */
$couponService = app()->make(StoreCouponIssueServices::class);
$data['list'] = $couponService->getTodayCoupon($uid);
$data['image'] = '';
return app('json')->success($data);
}
1 month ago
//wmc api
//台桌列表
public function getTableList(Request $request, $cate_id)
{
$list = Db::name('table_qrcode')
->where('cate_id', $cate_id)
->where('is_use', 0)
->select()->toArray();
return app('json')->success('ok', $list);
}
//台桌详情
public function getTableDetail(Request $request, $id)
{
$info = Db::name('table_qrcode')
1 month ago
->where('id', $id)
1 month ago
->find();
//营销经理列表
$info['yingxiao'] = Db::name('user')
->field('uid,nickname')
->where('group_id', 2)
->select();
return app('json')->success('ok', $info);
}
//台桌预定
public function tableYuDing(Request $request)
{
$uid = (int)$request->uid();
1 month ago
// if(!$uid){
// return app('json')->fail('预定失败,请先登录');
// }
1 month ago
$post = $request->postMore([
['table_id', 0],
['user_id', $uid],
['phone', 0],
['yuding_date', 0],
['come_date', 0],
['create', time()],
['admin_id', ''],
['remark', ''],
1 month ago
['store_id',1]
1 month ago
]);
//校验这个桌子有无在使用
1 month ago
$info = Db::name('table_qrcode')
->where('id', $post['table_id'])
->find();
if(!$info){
return app('json')->fail('预定失败');
}
if($info['is_use'] != 0){
return app('json')->fail('预定失败,台桌正在使用中');
}
1 month ago
//插入预定表
1 month ago
Db::name('table_yuding')->insert($post);
1 month ago
//改桌子状态
1 month ago
Db::name('table_qrcode')->where('id',$post['table_id'])->update(['is_use'=>2]);
return app('json')->success('预定成功');
}
1 month ago
1 month ago
//存酒记录
public function getcunjiu(Request $request)
{
$uid = (int)$request->uid();
1 month ago
1 month ago
if(!$uid){
$list = [];
}else{
$list = Db::name('store_drink_save')
->order('id desc')
->where('uid', $uid)
->select()->toArray();
foreach ($list as &$v){
$v['table_number'] = Db::name('table_qrcode')
->where('id', $v['table_id'])
->value('table_number');
$v['c_time'] = date('Y-m-d H:i:s',$v['create']);
}
}
1 month ago
1 month ago
return app('json')->success('ok', $list);
1 month ago
}
1 month ago
//取酒记录
public function getqujiu(Request $request)
{
$uid = (int)$request->uid();
if(!$uid){
$list = [];
}else{
$list = Db::name('store_drink_log')
->alias('a')
->order('a.id desc')
->leftJoin('eb_store_drink_save b', 'a.pid = b.id')
->field('b.*,a.content')
->where('a.uid', $uid)
->where('a.type',2)
->select()->toArray();
foreach ($list as &$v){
$v['table_number'] = Db::name('table_qrcode')
->where('id', $v['table_id'])
->value('table_number');
$v['c_time'] = date('Y-m-d H:i:s',$v['create']);
$str = $v['content'];
$startPos = strpos($str, '】');
$endPos = strpos($str, '瓶', $startPos);
if ($startPos!== false && $endPos!== false) {
$number = substr($str, $startPos + 5, $endPos - $startPos - 5);
}
$v['num'] = $number;
}
}
return app('json')->success('操作成功',$list);
}
1 month ago
2 months ago
}