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/ /.idea/
.editorconfig .editorconfig
.env .env
composer.lock
/vendor /vendor
/storage/app /storage/app
/storage/logs /storage/logs

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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