0
0

更新代码

This commit is contained in:
2020-08-04 10:09:42 +08:00
parent 6118b5b63b
commit c2ac5d964e
478 changed files with 34410 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
# Identity 身份系统
# trait User 模型 涉及函数 RuLong\Identity\Traits\UserHasIdentity
# 身份变更 $User->identityUpdate(Identity_id,Channel) // (身份ID,变更渠道)
# 身份加权点数 $User->addPoint(Identity_id,Point) // (身份ID,加权数额默认1)

View File

@@ -0,0 +1,27 @@
{
"name": "rulong/coupon",
"description": "",
"license": "MIT",
"authors": [
{
"name": "C.Jason",
"email": "chenjxlg@163.com"
}
],
"require": {
"php": ">=7.1.3",
"laravel/framework": "*"
},
"autoload": {
"psr-0": {
"RuLong\\Coupon": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"RuLong\\Coupon\\ServiceProvider"
]
}
}
}

View File

@@ -0,0 +1,19 @@
<?php
return [
'user_model' => \App\User::class,
'type' => [
'direct' => '直购',
'discount' => '折扣',
'reduction' => '满减',
'lesson' => '报名课程',
'lottery' => '抽奖',
],
'time_type' => [
'specified' => '指定时间',
'obtain' => '获取后',
],
'channel' => [
'Buy' => '购买',
'Gift' => '赠与',
],
];

View File

@@ -0,0 +1,17 @@
<?php
namespace RuLong\Coupon;
class Coupon
{
protected $contracts;
public function __construct(IdentityContracts $contracts)
{
}
public function __destruct()
{
}
}

View File

@@ -0,0 +1,119 @@
<?php
namespace RuLong\Coupon\Models;
use RuLong\Coupon\Models\CouponUserLog;
use RuLong\Order\Contracts\Orderable;
class CouponInfo extends Model implements Orderable
{
protected $dates = [
'start_at',
'end_at',
];
//返回券码类型
public function getTypeTextAttribute()
{
return config('rulong_coupon.type')[$this->type] ?? '无';
}
public function seller()
{
return $this->belongsTo(Seller::class)->withDefault();
}
public function getStateAttribute()
{
//下架
if ($this->status != 1) {
return 2;
}
//未开始
if ($this->start_at > now()) {
return 0;
}
//已结束
if ($this->end_at < now()) {
return -1;
}
//正常
if ($this->start_at <= now() && $this->end_at >= now()) {
return 1;
}
}
protected function getStatusTextAttribute()
{
if ($this->state === 0) {
return "<span style='color:blue'>未开始</span>";
} elseif ($this->state == 1) {
return "<span style='color:green'>正常</span>";
} elseif ($this->state == -1) {
return "<span style='color:blue'>已过期</span>";
} elseif ($this->state == 2) {
return "<span style='color:red'>已下架</span>";
}
}
public function logs()
{
return $this->hasMany(CouponUserLog::class, 'coupon_id', 'id');
}
/**
* 是否可下架
* @Author:<ZhaoxiaWang>
* @Date:2018-12-10
* @return boolean
*/
public function canCancel(): bool
{
return $this->status == 1 ? true : false;
}
public function getTitle()
{
return $this->title . '-' . $this->bouns;
}
public function getPrice()
{
return $this->bouns;
}
public function getScore()
{
return 0;
}
public function getStock()
{
return 0;
}
public function getSellerPrice()
{
return $this->bouns;
}
public function deductStock($stock)
{
}
public function addStock($stock)
{
}
public function getStorage()
{
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace RuLong\Coupon\Models;
class CouponLog extends Model
{
//
}

View File

@@ -0,0 +1,8 @@
<?php
namespace RuLong\Coupon\Models;
class CouponRule extends Model
{
//
}

View File

@@ -0,0 +1,8 @@
<?php
namespace RuLong\Coupon\Models;
class CouponUse extends Model
{
//
}

View File

@@ -0,0 +1,19 @@
<?php
namespace RuLong\Coupon\Models;
use App\User;
use RuLong\Coupon\Models\CouponInfo;
class CouponUserLog extends Model
{
public function info()
{
return $this->belongsTo(CouponInfo::class, 'coupon_id', 'id');
}
public function user()
{
return $this->belongsTo(User::class);
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace RuLong\Coupon\Models;
use Illuminate\Database\Eloquent\Model as EloquentModel;
class Model extends EloquentModel
{
protected $guarded = [];
}

View File

@@ -0,0 +1,34 @@
<?php
namespace RuLong\Coupon;
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
class ServiceProvider extends LaravelServiceProvider
{
/**
* 部署时加载
* @Author:<C.Jason>
* @Date:2018-06-22T16:01:20+0800
* @return [type] [description]
*/
public function boot()
{
if ($this->app->runningInConsole()) {
$this->publishes([__DIR__ . '/../config/rulong_coupon.php' => config_path('rulong_coupon.php')]);
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations/');
}
}
/**
* 注册服务提供者
* @Author:<C.Jason>
* @Date:2018-06-22T16:01:12+0800
* @return [type] [description]
*/
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/../config/rulong_coupon.php', 'rulong_coupon');
}
}