Compare commits
9 Commits
a7719d7038
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 8890db9965 | |||
| d7fb364d8e | |||
| 29ddef3ad9 | |||
| ba272c6a87 | |||
| 5e16b131b9 | |||
| 10cdc899e1 | |||
| 99c6991b79 | |||
| 889e09cdd1 | |||
| 538306bb4f |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,6 +2,7 @@
|
|||||||
/.idea/
|
/.idea/
|
||||||
.editorconfig
|
.editorconfig
|
||||||
.env
|
.env
|
||||||
|
composer.lock
|
||||||
/vendor
|
/vendor
|
||||||
/storage/app
|
/storage/app
|
||||||
/storage/logs
|
/storage/logs
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ class CouponController extends AdminController
|
|||||||
$filter->column(1 / 2, function ($filter) {
|
$filter->column(1 / 2, function ($filter) {
|
||||||
$filter->equal('status', '状态')->select(ActivityCoupon::STATUS);
|
$filter->equal('status', '状态')->select(ActivityCoupon::STATUS);
|
||||||
$filter->between('used_at', '核销时间')->datetime();
|
$filter->between('used_at', '核销时间')->datetime();
|
||||||
|
|
||||||
|
|
||||||
$filter->where(function ($query) {
|
$filter->where(function ($query) {
|
||||||
$query->whereHas('outlet', function ($query) {
|
$query->whereHas('outlet', function ($query) {
|
||||||
$query->whereHas('info', function ($query) {
|
$query->whereHas('info', function ($query) {
|
||||||
@@ -54,7 +52,6 @@ class CouponController extends AdminController
|
|||||||
})
|
})
|
||||||
->get()
|
->get()
|
||||||
->pluck('nickname', 'id');
|
->pluck('nickname', 'id');
|
||||||
|
|
||||||
$filter->where(function ($query) {
|
$filter->where(function ($query) {
|
||||||
$query->whereHas('outlet', function ($query) {
|
$query->whereHas('outlet', function ($query) {
|
||||||
$query->whereHas('parent', function ($query) {
|
$query->whereHas('parent', function ($query) {
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ class IndexController extends AdminController
|
|||||||
->when(Activity::TYPE_SCOPE, function (Form $form) {
|
->when(Activity::TYPE_SCOPE, function (Form $form) {
|
||||||
$form->dateRange('start_at', 'end_at', '有效时间');
|
$form->dateRange('start_at', 'end_at', '有效时间');
|
||||||
})
|
})
|
||||||
|
->help('当月券,领取的月底到期')
|
||||||
->required();
|
->required();
|
||||||
|
|
||||||
$form->radio('channel', '核销途径')
|
$form->radio('channel', '核销途径')
|
||||||
@@ -120,6 +121,7 @@ class IndexController extends AdminController
|
|||||||
->default(Activity::CHANNEL_YSD)
|
->default(Activity::CHANNEL_YSD)
|
||||||
->help('券码核销的途径:亿时代是自己核销,银联是银联pos核销')
|
->help('券码核销的途径:亿时代是自己核销,银联是银联pos核销')
|
||||||
->required();
|
->required();
|
||||||
|
$form->number('day_times', '每天可用次数')->default(0)->help('每天可用次数,0未不限制');
|
||||||
|
|
||||||
$form->switch('status', '状态')->default(1);
|
$form->switch('status', '状态')->default(1);
|
||||||
$form->switch('need_check', '多次校验')
|
$form->switch('need_check', '多次校验')
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ trait ApiResponse
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* [$statusCode description]
|
* [$statusCode description]
|
||||||
|
*
|
||||||
* @var [type]
|
* @var [type]
|
||||||
*/
|
*/
|
||||||
protected $statusCode = FoundationResponse::HTTP_OK;
|
protected $statusCode = FoundationResponse::HTTP_OK;
|
||||||
@@ -24,6 +25,7 @@ trait ApiResponse
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密
|
* 加密
|
||||||
|
*
|
||||||
* @param <type> $value
|
* @param <type> $value
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
@@ -40,6 +42,7 @@ trait ApiResponse
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 解密
|
* 解密
|
||||||
|
*
|
||||||
* @param <type> $value
|
* @param <type> $value
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
@@ -61,18 +64,18 @@ trait ApiResponse
|
|||||||
$data = $request->data ?? false;
|
$data = $request->data ?? false;
|
||||||
$addcode = $request->addcode ?? false;
|
$addcode = $request->addcode ?? false;
|
||||||
$sign = $request->sign ?? false;
|
$sign = $request->sign ?? false;
|
||||||
if (!$server_id) {
|
if (! $server_id) {
|
||||||
return '参数server_id不能为空';
|
return '参数server_id不能为空';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$key) {
|
if (! $key) {
|
||||||
return '参数key不能为空';
|
return '参数key不能为空';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->user = User::where('server_id', $server_id)
|
$this->user = User::where('server_id', $server_id)
|
||||||
->where('server_key', $key)->first();
|
->where('server_key', $key)->first();
|
||||||
|
|
||||||
if (!$this->user) {
|
if (! $this->user) {
|
||||||
return '参数server_id与key不匹配';
|
return '参数server_id与key不匹配';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,15 +83,15 @@ trait ApiResponse
|
|||||||
return '渠道商状态不正确';
|
return '渠道商状态不正确';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$sign) {
|
if (! $sign) {
|
||||||
return '参数sign不能为空';
|
return '参数sign不能为空';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$data) {
|
if (! $data) {
|
||||||
return '参数data不能为空';
|
return '参数data不能为空';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$addcode) {
|
if (! $addcode) {
|
||||||
return '参数addcode不能为空';
|
return '参数addcode不能为空';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +103,9 @@ trait ApiResponse
|
|||||||
}
|
}
|
||||||
$keydesc = $this->keydesc($data);
|
$keydesc = $this->keydesc($data);
|
||||||
$keydescArr = json_decode($this->keydesc($data), true);
|
$keydescArr = json_decode($this->keydesc($data), true);
|
||||||
if (empty($keydescArr) && !empty($keydesc)) {
|
if (empty($keydescArr) && ! empty($keydesc)) {
|
||||||
|
info(json_encode($keydescArr));
|
||||||
|
info(json_encode($keydesc));
|
||||||
return '传递的json数据不对';
|
return '传递的json数据不对';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +114,7 @@ trait ApiResponse
|
|||||||
|
|
||||||
public function keysign($jsonData = '', $addcode = '')
|
public function keysign($jsonData = '', $addcode = '')
|
||||||
{
|
{
|
||||||
$signStr = 'data=' . $jsonData . '&addcode=' . $addcode . '&key=' . $this->user->server_key;
|
$signStr = 'data='.$jsonData.'&addcode='.$addcode.'&key='.$this->user->server_key;
|
||||||
$sign = hash_hmac('sha256', $signStr, $this->user->server_key);
|
$sign = hash_hmac('sha256', $signStr, $this->user->server_key);
|
||||||
|
|
||||||
return $sign;
|
return $sign;
|
||||||
@@ -117,6 +122,7 @@ trait ApiResponse
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 成功的返回
|
* 成功的返回
|
||||||
|
*
|
||||||
* @Author :<C.Jason>
|
* @Author :<C.Jason>
|
||||||
* @Date :2018-05-22
|
* @Date :2018-05-22
|
||||||
* @param [type] $data [description]
|
* @param [type] $data [description]
|
||||||
@@ -138,7 +144,7 @@ trait ApiResponse
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ($log) {
|
if ($log) {
|
||||||
if (!is_array($data)) {
|
if (! is_array($data)) {
|
||||||
$data = [$data];
|
$data = [$data];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +172,7 @@ trait ApiResponse
|
|||||||
{
|
{
|
||||||
$rt = microtime(true) - LARAVEL_START;
|
$rt = microtime(true) - LARAVEL_START;
|
||||||
|
|
||||||
$header = array_merge($header, ['rt' => round($rt * 1000, 2) . 'ms', 'qps' => round(1 / $rt, 1)]);
|
$header = array_merge($header, ['rt' => round($rt * 1000, 2).'ms', 'qps' => round(1 / $rt, 1)]);
|
||||||
|
|
||||||
return Response::json($data, $code, $header);
|
return Response::json($data, $code, $header);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ class Activity extends Model
|
|||||||
|
|
||||||
const TYPE_EXTEND = 1;
|
const TYPE_EXTEND = 1;
|
||||||
const TYPE_SCOPE = 2;
|
const TYPE_SCOPE = 2;
|
||||||
|
const TYPE_MONTH = 3;
|
||||||
const TYPES = [
|
const TYPES = [
|
||||||
self::TYPE_EXTEND => '延期',
|
self::TYPE_EXTEND => '延期',
|
||||||
self::TYPE_SCOPE => '固定',
|
self::TYPE_SCOPE => '固定',
|
||||||
|
self::TYPE_MONTH => '当月',
|
||||||
];
|
];
|
||||||
|
|
||||||
const STATUS_OPEN = 1;
|
const STATUS_OPEN = 1;
|
||||||
@@ -201,6 +203,9 @@ class Activity extends Model
|
|||||||
if ($this->type == SELF::TYPE_EXTEND) {
|
if ($this->type == SELF::TYPE_EXTEND) {
|
||||||
$start_at = now();
|
$start_at = now();
|
||||||
$end_at = now()->addDays($this->days);
|
$end_at = now()->addDays($this->days);
|
||||||
|
} elseif ($this->type == self::TYPE_MONTH) {
|
||||||
|
$start_at = now();
|
||||||
|
$end_at = now()->endOfMonth();
|
||||||
} else {
|
} else {
|
||||||
$start_at = $this->start_at->startOfDay();
|
$start_at = $this->start_at->startOfDay();
|
||||||
$end_at = $this->end_at->endOfDay();
|
$end_at = $this->end_at->endOfDay();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class ActivityCoupon extends Model
|
|||||||
* @Date : 2020/6/30 9:40
|
* @Date : 2020/6/30 9:40
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getStatusTextAttribute()
|
public function getStatusTextAttribute(): string
|
||||||
{
|
{
|
||||||
return self::STATUS[$this->status] ?? '未知';
|
return self::STATUS[$this->status] ?? '未知';
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ class ActivityCoupon extends Model
|
|||||||
* @Date : 2020/6/30 9:41
|
* @Date : 2020/6/30 9:41
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function canRedemption()
|
public function canRedemption(): bool
|
||||||
{
|
{
|
||||||
return $this->status == ActivityCoupon::STATUS_INIT;
|
return $this->status == ActivityCoupon::STATUS_INIT;
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ class ActivityCoupon extends Model
|
|||||||
* @Date : 2020/6/30 9:41
|
* @Date : 2020/6/30 9:41
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function canDestroy()
|
public function canDestroy(): bool
|
||||||
{
|
{
|
||||||
return $this->canRedemption();
|
return $this->canRedemption();
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ class ActivityCoupon extends Model
|
|||||||
* @Date : 2020/10/12 11:57
|
* @Date : 2020/10/12 11:57
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function canReversal()
|
public function canReversal(): bool
|
||||||
{
|
{
|
||||||
return $this->status == self::STATUS_USED;
|
return $this->status == self::STATUS_USED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
|||||||
|
|
||||||
use App\Models\Traits\BelongsToOutlet;
|
use App\Models\Traits\BelongsToOutlet;
|
||||||
use App\Models\Traits\BelongsToUser;
|
use App\Models\Traits\BelongsToUser;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
|
||||||
class Coupon extends Model
|
class Coupon extends Model
|
||||||
{
|
{
|
||||||
@@ -30,7 +31,7 @@ class Coupon extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
//状态
|
//状态
|
||||||
public function getStatusTextAttribute()
|
public function getStatusTextAttribute(): string
|
||||||
{
|
{
|
||||||
switch ($this->status) {
|
switch ($this->status) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -54,7 +55,7 @@ class Coupon extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProfitTextAttribute()
|
public function getProfitTextAttribute(): string
|
||||||
{
|
{
|
||||||
switch ($this->is_profit) {
|
switch ($this->is_profit) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -75,7 +76,7 @@ class Coupon extends Model
|
|||||||
* @return bool [type] [description]
|
* @return bool [type] [description]
|
||||||
* @author 玄尘 2020-03-13
|
* @author 玄尘 2020-03-13
|
||||||
*/
|
*/
|
||||||
public function canProfit()
|
public function canProfit(): bool
|
||||||
{
|
{
|
||||||
return ($this->is_profit === 0 && $this->status == 2);
|
return ($this->is_profit === 0 && $this->status == 2);
|
||||||
}
|
}
|
||||||
@@ -183,4 +184,12 @@ class Coupon extends Model
|
|||||||
return $this->created_at->format('Y-m-d');
|
return $this->created_at->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 关联自有券
|
||||||
|
*/
|
||||||
|
public function activityCoupon(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(ActivityCoupon::class, 'code', 'redemptionCode');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
10327
composer.lock
generated
10327
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddDayTimesToActivitiesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('activities', function (Blueprint $table) {
|
||||||
|
$table->integer('day_times')->default(0)->comment('每天可用次数');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('activities', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user