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/
|
||||
.editorconfig
|
||||
.env
|
||||
composer.lock
|
||||
/vendor
|
||||
/storage/app
|
||||
/storage/logs
|
||||
|
||||
@@ -24,8 +24,6 @@ class CouponController extends AdminController
|
||||
$filter->column(1 / 2, function ($filter) {
|
||||
$filter->equal('status', '状态')->select(ActivityCoupon::STATUS);
|
||||
$filter->between('used_at', '核销时间')->datetime();
|
||||
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('info', function ($query) {
|
||||
@@ -54,7 +52,6 @@ class CouponController extends AdminController
|
||||
})
|
||||
->get()
|
||||
->pluck('nickname', 'id');
|
||||
|
||||
$filter->where(function ($query) {
|
||||
$query->whereHas('outlet', function ($query) {
|
||||
$query->whereHas('parent', function ($query) {
|
||||
|
||||
@@ -113,6 +113,7 @@ class IndexController extends AdminController
|
||||
->when(Activity::TYPE_SCOPE, function (Form $form) {
|
||||
$form->dateRange('start_at', 'end_at', '有效时间');
|
||||
})
|
||||
->help('当月券,领取的月底到期')
|
||||
->required();
|
||||
|
||||
$form->radio('channel', '核销途径')
|
||||
@@ -120,6 +121,7 @@ class IndexController extends AdminController
|
||||
->default(Activity::CHANNEL_YSD)
|
||||
->help('券码核销的途径:亿时代是自己核销,银联是银联pos核销')
|
||||
->required();
|
||||
$form->number('day_times', '每天可用次数')->default(0)->help('每天可用次数,0未不限制');
|
||||
|
||||
$form->switch('status', '状态')->default(1);
|
||||
$form->switch('need_check', '多次校验')
|
||||
|
||||
@@ -16,6 +16,7 @@ trait ApiResponse
|
||||
|
||||
/**
|
||||
* [$statusCode description]
|
||||
*
|
||||
* @var [type]
|
||||
*/
|
||||
protected $statusCode = FoundationResponse::HTTP_OK;
|
||||
@@ -24,6 +25,7 @@ trait ApiResponse
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*
|
||||
* @param <type> $value
|
||||
* @return <type>
|
||||
*/
|
||||
@@ -40,6 +42,7 @@ trait ApiResponse
|
||||
|
||||
/**
|
||||
* 解密
|
||||
*
|
||||
* @param <type> $value
|
||||
* @return <type>
|
||||
*/
|
||||
@@ -61,18 +64,18 @@ trait ApiResponse
|
||||
$data = $request->data ?? false;
|
||||
$addcode = $request->addcode ?? false;
|
||||
$sign = $request->sign ?? false;
|
||||
if (!$server_id) {
|
||||
if (! $server_id) {
|
||||
return '参数server_id不能为空';
|
||||
}
|
||||
|
||||
if (!$key) {
|
||||
if (! $key) {
|
||||
return '参数key不能为空';
|
||||
}
|
||||
|
||||
$this->user = User::where('server_id', $server_id)
|
||||
->where('server_key', $key)->first();
|
||||
|
||||
if (!$this->user) {
|
||||
if (! $this->user) {
|
||||
return '参数server_id与key不匹配';
|
||||
}
|
||||
|
||||
@@ -80,15 +83,15 @@ trait ApiResponse
|
||||
return '渠道商状态不正确';
|
||||
}
|
||||
|
||||
if (!$sign) {
|
||||
if (! $sign) {
|
||||
return '参数sign不能为空';
|
||||
}
|
||||
|
||||
if (!$data) {
|
||||
if (! $data) {
|
||||
return '参数data不能为空';
|
||||
}
|
||||
|
||||
if (!$addcode) {
|
||||
if (! $addcode) {
|
||||
return '参数addcode不能为空';
|
||||
}
|
||||
|
||||
@@ -100,7 +103,9 @@ trait ApiResponse
|
||||
}
|
||||
$keydesc = $this->keydesc($data);
|
||||
$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数据不对';
|
||||
}
|
||||
|
||||
@@ -109,7 +114,7 @@ trait ApiResponse
|
||||
|
||||
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);
|
||||
|
||||
return $sign;
|
||||
@@ -117,6 +122,7 @@ trait ApiResponse
|
||||
|
||||
/**
|
||||
* 成功的返回
|
||||
*
|
||||
* @Author :<C.Jason>
|
||||
* @Date :2018-05-22
|
||||
* @param [type] $data [description]
|
||||
@@ -138,7 +144,7 @@ trait ApiResponse
|
||||
];
|
||||
|
||||
if ($log) {
|
||||
if (!is_array($data)) {
|
||||
if (! is_array($data)) {
|
||||
$data = [$data];
|
||||
}
|
||||
|
||||
@@ -166,7 +172,7 @@ trait ApiResponse
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
@@ -20,9 +20,11 @@ class Activity extends Model
|
||||
|
||||
const TYPE_EXTEND = 1;
|
||||
const TYPE_SCOPE = 2;
|
||||
const TYPE_MONTH = 3;
|
||||
const TYPES = [
|
||||
self::TYPE_EXTEND => '延期',
|
||||
self::TYPE_SCOPE => '固定',
|
||||
self::TYPE_MONTH => '当月',
|
||||
];
|
||||
|
||||
const STATUS_OPEN = 1;
|
||||
@@ -201,6 +203,9 @@ class Activity extends Model
|
||||
if ($this->type == SELF::TYPE_EXTEND) {
|
||||
$start_at = now();
|
||||
$end_at = now()->addDays($this->days);
|
||||
} elseif ($this->type == self::TYPE_MONTH) {
|
||||
$start_at = now();
|
||||
$end_at = now()->endOfMonth();
|
||||
} else {
|
||||
$start_at = $this->start_at->startOfDay();
|
||||
$end_at = $this->end_at->endOfDay();
|
||||
|
||||
@@ -37,7 +37,7 @@ class ActivityCoupon extends Model
|
||||
* @Date : 2020/6/30 9:40
|
||||
* @return string
|
||||
*/
|
||||
public function getStatusTextAttribute()
|
||||
public function getStatusTextAttribute(): string
|
||||
{
|
||||
return self::STATUS[$this->status] ?? '未知';
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class ActivityCoupon extends Model
|
||||
* @Date : 2020/6/30 9:41
|
||||
* @return bool
|
||||
*/
|
||||
public function canRedemption()
|
||||
public function canRedemption(): bool
|
||||
{
|
||||
return $this->status == ActivityCoupon::STATUS_INIT;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ class ActivityCoupon extends Model
|
||||
* @Date : 2020/6/30 9:41
|
||||
* @return bool
|
||||
*/
|
||||
public function canDestroy()
|
||||
public function canDestroy(): bool
|
||||
{
|
||||
return $this->canRedemption();
|
||||
}
|
||||
@@ -70,7 +70,7 @@ class ActivityCoupon extends Model
|
||||
* @Date : 2020/10/12 11:57
|
||||
* @return bool
|
||||
*/
|
||||
public function canReversal()
|
||||
public function canReversal(): bool
|
||||
{
|
||||
return $this->status == self::STATUS_USED;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Models\Traits\BelongsToOutlet;
|
||||
use App\Models\Traits\BelongsToUser;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
class Coupon extends Model
|
||||
{
|
||||
@@ -30,7 +31,7 @@ class Coupon extends Model
|
||||
];
|
||||
|
||||
//状态
|
||||
public function getStatusTextAttribute()
|
||||
public function getStatusTextAttribute(): string
|
||||
{
|
||||
switch ($this->status) {
|
||||
case 0:
|
||||
@@ -54,7 +55,7 @@ class Coupon extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function getProfitTextAttribute()
|
||||
public function getProfitTextAttribute(): string
|
||||
{
|
||||
switch ($this->is_profit) {
|
||||
case 0:
|
||||
@@ -75,7 +76,7 @@ class Coupon extends Model
|
||||
* @return bool [type] [description]
|
||||
* @author 玄尘 2020-03-13
|
||||
*/
|
||||
public function canProfit()
|
||||
public function canProfit(): bool
|
||||
{
|
||||
return ($this->is_profit === 0 && $this->status == 2);
|
||||
}
|
||||
@@ -183,4 +184,12 @@ class Coupon extends Model
|
||||
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