增加来源
This commit is contained in:
9
bootstrap/cache/events.php
vendored
Normal file
9
bootstrap/cache/events.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php return array (
|
||||||
|
'App\\Providers\\EventServiceProvider' =>
|
||||||
|
array (
|
||||||
|
'App\\Events\\ConponCallback' =>
|
||||||
|
array (
|
||||||
|
0 => 'App\\Listeners\\ConponCallbackListener',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
@@ -35,6 +35,9 @@ class Init
|
|||||||
//订单id
|
//订单id
|
||||||
public $orderid;
|
public $orderid;
|
||||||
|
|
||||||
|
//来源
|
||||||
|
public $from;
|
||||||
|
|
||||||
//查询到的卡券规则和商品id 只有平安券才有
|
//查询到的卡券规则和商品id 只有平安券才有
|
||||||
public $queryData;
|
public $queryData;
|
||||||
|
|
||||||
@@ -99,6 +102,15 @@ class Init
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//设置来源
|
||||||
|
public function setFrom($from)
|
||||||
|
{
|
||||||
|
$this->from = $from;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notes: 插入日志
|
* Notes: 插入日志
|
||||||
* @Author: 玄尘
|
* @Author: 玄尘
|
||||||
@@ -139,6 +151,10 @@ class Init
|
|||||||
//统一门店 相同金额 3分钟之内看作是一笔订单
|
//统一门店 相同金额 3分钟之内看作是一笔订单
|
||||||
public function CheckCount()
|
public function CheckCount()
|
||||||
{
|
{
|
||||||
|
if (!empty($this->from) && in_array($this->from, [''])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->queryData) {
|
if ($this->queryData) {
|
||||||
if (isset($this->queryData['thirdPartyGoodsId']) && $this->queryData['thirdPartyGoodsId'] == 'YSD-full0-0') {
|
if (isset($this->queryData['thirdPartyGoodsId']) && $this->queryData['thirdPartyGoodsId'] == 'YSD-full0-0') {
|
||||||
return true;
|
return true;
|
||||||
@@ -147,23 +163,23 @@ class Init
|
|||||||
|
|
||||||
if ($this->orderid) {
|
if ($this->orderid) {
|
||||||
$check_count = Coupon::where('orderid', $this->orderid)
|
$check_count = Coupon::where('orderid', $this->orderid)
|
||||||
->where('outletId', $this->outletId)
|
->where('outletId', $this->outletId)
|
||||||
->where('total', $this->total)
|
->where('total', $this->total)
|
||||||
->where('status', 2)
|
->where('status', 2)
|
||||||
->where('created_at', '>=', now()->subMinutes(3)->format('Y-m-d H:i:s'))
|
->where('created_at', '>=', now()->subMinutes(3)->format('Y-m-d H:i:s'))
|
||||||
->count();
|
->count();
|
||||||
} else {
|
} else {
|
||||||
$check_count = Coupon::where('outletId', $this->outletId)
|
$check_count = Coupon::where('outletId', $this->outletId)
|
||||||
->where('total', $this->total)
|
->where('total', $this->total)
|
||||||
->where('status', 2)
|
->where('status', 2)
|
||||||
->where('created_at', '>=', now()->subMinutes(3)->format('Y-m-d H:i:s'))
|
->where('created_at', '>=', now()->subMinutes(3)->format('Y-m-d H:i:s'))
|
||||||
->count();
|
->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
$count = floor($this->total / 100);
|
$count = floor($this->total / 100);
|
||||||
|
|
||||||
if ($check_count > 0) {
|
if ($check_count > 0) {
|
||||||
// if ($this->total < 100) {
|
// if ($this->total < 100) {
|
||||||
// return '核销失败,订单金额少于100只能核销一张优惠券。';
|
// return '核销失败,订单金额少于100只能核销一张优惠券。';
|
||||||
// }
|
// }
|
||||||
if ($check_count >= $count) {
|
if ($check_count >= $count) {
|
||||||
@@ -182,10 +198,10 @@ class Init
|
|||||||
public function HasCheck()
|
public function HasCheck()
|
||||||
{
|
{
|
||||||
$info = Coupon::where('redemptionCode', $this->redemptionCode)
|
$info = Coupon::where('redemptionCode', $this->redemptionCode)
|
||||||
->where('outletId', $this->outletId)
|
->where('outletId', $this->outletId)
|
||||||
->where('total', $this->total)
|
->where('total', $this->total)
|
||||||
->where('status', 2)
|
->where('status', 2)
|
||||||
->first();
|
->first();
|
||||||
if ($info) {
|
if ($info) {
|
||||||
return '核销失败,此优惠券已被使用';
|
return '核销失败,此优惠券已被使用';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,9 +117,17 @@ class Coupon
|
|||||||
* @param float $total 订单金额
|
* @param float $total 订单金额
|
||||||
* @param string $outletId 网点id
|
* @param string $outletId 网点id
|
||||||
* @param string $orderid 订单id
|
* @param string $orderid 订单id
|
||||||
|
* @param string $from 来源
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function Redemption(User $user, string $redemptionCode, float $total, string $outletId, string $orderid = '')
|
public static function Redemption(
|
||||||
|
User $user,
|
||||||
|
string $redemptionCode,
|
||||||
|
float $total,
|
||||||
|
string $outletId,
|
||||||
|
string $orderid = '',
|
||||||
|
string $from = ''
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -133,6 +141,7 @@ class Coupon
|
|||||||
->setTotal($total)
|
->setTotal($total)
|
||||||
->setOutletId($outletId)
|
->setOutletId($outletId)
|
||||||
->setOrderId($orderid)
|
->setOrderId($orderid)
|
||||||
|
->setFrom($from)
|
||||||
->start();
|
->start();
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user