Compare commits

...

9 Commits

Author SHA1 Message Date
8890db9965 删除一些调试代码 2024-03-06 11:21:22 +08:00
d7fb364d8e 输出调试代码 2024-03-06 11:10:41 +08:00
29ddef3ad9 输出调试代码 2024-03-06 11:02:21 +08:00
ba272c6a87 输出调试代码 2024-03-06 10:53:43 +08:00
5e16b131b9 调整冲突 2023-05-16 14:25:29 +08:00
10cdc899e1 配置忽略文件 2023-05-16 13:08:42 +08:00
99c6991b79 删除composer.lock 2023-05-16 11:25:23 +08:00
889e09cdd1 微调 2023-05-16 11:24:14 +08:00
538306bb4f 调整活动 2023-05-16 11:23:35 +08:00
9 changed files with 76 additions and 10351 deletions

1
.gitignore vendored
View File

@@ -2,6 +2,7 @@
/.idea/
.editorconfig
.env
composer.lock
/vendor
/storage/app
/storage/logs

View File

@@ -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) {

View File

@@ -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', '多次校验')

View File

@@ -16,6 +16,7 @@ trait ApiResponse
/**
* [$statusCode description]
*
* @var [type]
*/
protected $statusCode = FoundationResponse::HTTP_OK;
@@ -24,7 +25,8 @@ trait ApiResponse
/**
* 加密
* @param <type> $value
*
* @param <type> $value
* @return <type>
*/
public function keyasc($value)
@@ -40,7 +42,8 @@ trait ApiResponse
/**
* 解密
* @param <type> $value
*
* @param <type> $value
* @return <type>
*/
public function keydesc($value)
@@ -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();
->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,10 +122,11 @@ trait ApiResponse
/**
* 成功的返回
*
* @Author :<C.Jason>
* @Date :2018-05-22
* @param [type] $data [description]
* @param string $log
* @param string $log
* @return [type] [description]
*/
public function success($data, $log = '')
@@ -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);
}

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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

File diff suppressed because it is too large Load Diff

View File

@@ -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) {
//
});
}
}