first commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* The file was created by Assimon.
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BaseModel extends Model
|
||||
{
|
||||
|
||||
const STATUS_OPEN = 1; // 状态开启
|
||||
const STATUS_CLOSE = 0; // 状态关闭
|
||||
|
||||
const AUTOMATIC_DELIVERY = 1; // 自动发货
|
||||
const MANUAL_PROCESSING = 2; // 人工处理
|
||||
|
||||
/**
|
||||
* map
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public static function getIsOpenMap()
|
||||
{
|
||||
return [
|
||||
self::STATUS_OPEN => admin_trans('dujiaoka.status_open'),
|
||||
self::STATUS_CLOSE => admin_trans('dujiaoka.status_close')
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Carmis extends BaseModel
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'carmis';
|
||||
|
||||
/**
|
||||
* 未售出
|
||||
*/
|
||||
const STATUS_UNSOLD = 1;
|
||||
|
||||
/**
|
||||
* 已售出
|
||||
*/
|
||||
const STATUS_SOLD = 2;
|
||||
|
||||
/**
|
||||
* 获取组建映射
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public static function getStatusMap()
|
||||
{
|
||||
return [
|
||||
self::STATUS_UNSOLD => admin_trans('carmis.fields.status_unsold'),
|
||||
self::STATUS_SOLD => admin_trans('carmis.fields.status_sold')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联商品
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function goods()
|
||||
{
|
||||
return $this->belongsTo(Goods::class, 'goods_id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Coupon extends BaseModel
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'coupons';
|
||||
|
||||
/**
|
||||
* 一次性使用
|
||||
*/
|
||||
const TYPE_ONE_TIME = 1;
|
||||
|
||||
/**
|
||||
* 重复使用
|
||||
*/
|
||||
const TYPE_REPEAT = 2;
|
||||
|
||||
/**
|
||||
* 未使用
|
||||
*/
|
||||
const STATUS_UNUSED = 1;
|
||||
|
||||
/**
|
||||
* 已使用
|
||||
*/
|
||||
const STATUS_USE = 2;
|
||||
|
||||
/**
|
||||
* 关联商品
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function goods()
|
||||
{
|
||||
return $this->belongsToMany(Goods::class, 'coupons_goods', 'coupons_id', 'goods_id');
|
||||
}
|
||||
|
||||
|
||||
public static function getStatusUseMap()
|
||||
{
|
||||
return [
|
||||
self::STATUS_USE => admin_trans('coupon.fields.status_use'),
|
||||
self::STATUS_UNUSED => admin_trans('coupon.fields.status_unused'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Emailtpl extends Model
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'emailtpls';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Events\GoodsDeleted;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Goods extends BaseModel
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'goods';
|
||||
|
||||
protected $dispatchesEvents = [
|
||||
'deleted' => GoodsDeleted::class
|
||||
];
|
||||
|
||||
/**
|
||||
* 关联分类
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function group()
|
||||
{
|
||||
return $this->belongsTo(GoodsGroup::class, 'group_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联优惠券
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function coupon()
|
||||
{
|
||||
return $this->belongsToMany(Coupon::class, 'coupons_goods', 'goods_id', 'coupons_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联卡密
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function carmis()
|
||||
{
|
||||
return $this->hasMany(Carmis::class, 'goods_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存读取器,将自动发货的库存更改为未出售卡密的数量
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function getInStockAttribute()
|
||||
{
|
||||
if (isset($this->attributes['carmis_count'])
|
||||
&&
|
||||
$this->attributes['type'] == self::AUTOMATIC_DELIVERY
|
||||
) {
|
||||
$this->attributes['in_stock'] = $this->attributes['carmis_count'];
|
||||
}
|
||||
return $this->attributes['in_stock'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组建映射
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public static function getGoodsTypeMap()
|
||||
{
|
||||
return [
|
||||
self::AUTOMATIC_DELIVERY => admin_trans('goods.fields.automatic_delivery'),
|
||||
self::MANUAL_PROCESSING => admin_trans('goods.fields.manual_processing')
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
use App\Events\GoodsGroupDeleted;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class GoodsGroup extends BaseModel
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'goods_group';
|
||||
|
||||
protected $dispatchesEvents = [
|
||||
'deleted' => GoodsGroupDeleted::class
|
||||
];
|
||||
|
||||
/**
|
||||
* 关联商品
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function goods()
|
||||
{
|
||||
return $this->hasMany(Goods::class, 'group_id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Events\OrderUpdated;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Order extends BaseModel
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'orders';
|
||||
|
||||
/**
|
||||
* 待支付
|
||||
*/
|
||||
const STATUS_WAIT_PAY = 1;
|
||||
|
||||
/**
|
||||
* 待处理
|
||||
*/
|
||||
const STATUS_PENDING = 2;
|
||||
|
||||
/**
|
||||
* 处理中
|
||||
*/
|
||||
const STATUS_PROCESSING = 3;
|
||||
|
||||
/**
|
||||
* 已完成
|
||||
*/
|
||||
const STATUS_COMPLETED = 4;
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
const STATUS_FAILURE = 5;
|
||||
|
||||
/**
|
||||
* 过期
|
||||
*/
|
||||
const STATUS_EXPIRED = -1;
|
||||
|
||||
/**
|
||||
* 异常
|
||||
*/
|
||||
const STATUS_ABNORMAL = 6;
|
||||
|
||||
/**
|
||||
* 优惠券未回退
|
||||
*/
|
||||
const COUPON_BACK_WAIT = 0;
|
||||
|
||||
/**
|
||||
* 优惠券已回退
|
||||
*/
|
||||
const COUPON_BACK_OK = 1;
|
||||
|
||||
protected $dispatchesEvents = [
|
||||
'updated' => OrderUpdated::class
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 状态映射
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public static function getStatusMap()
|
||||
{
|
||||
return [
|
||||
self::STATUS_WAIT_PAY => admin_trans('order.fields.status_wait_pay'),
|
||||
self::STATUS_PENDING => admin_trans('order.fields.status_pending'),
|
||||
self::STATUS_PROCESSING => admin_trans('order.fields.status_processing'),
|
||||
self::STATUS_COMPLETED => admin_trans('order.fields.status_completed'),
|
||||
self::STATUS_FAILURE => admin_trans('order.fields.status_failure'),
|
||||
self::STATUS_ABNORMAL => admin_trans('order.fields.status_abnormal'),
|
||||
self::STATUS_EXPIRED => admin_trans('order.fields.status_expired')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 类型映射
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public static function getTypeMap()
|
||||
{
|
||||
return [
|
||||
self::AUTOMATIC_DELIVERY => admin_trans('goods.fields.automatic_delivery'),
|
||||
self::MANUAL_PROCESSING => admin_trans('goods.fields.manual_processing')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联商品
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function goods()
|
||||
{
|
||||
return $this->belongsTo(Goods::class, 'goods_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联优惠券
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function coupon()
|
||||
{
|
||||
return $this->belongsTo(Coupon::class, 'coupon_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联支付
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*
|
||||
* @author assimon<ashang@utf8.hk>
|
||||
* @copyright assimon<ashang@utf8.hk>
|
||||
* @link http://utf8.hk/
|
||||
*/
|
||||
public function pay()
|
||||
{
|
||||
return $this->belongsTo(Pay::class, 'pay_id');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Pay extends BaseModel
|
||||
{
|
||||
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'pays';
|
||||
|
||||
/**
|
||||
* 跳转
|
||||
*/
|
||||
const METHOD_JUMP = 1;
|
||||
|
||||
/**
|
||||
* 扫码
|
||||
*/
|
||||
const METHOD_SCAN = 2;
|
||||
|
||||
/**
|
||||
* 电脑
|
||||
*/
|
||||
const PAY_CLIENT_PC = 1;
|
||||
|
||||
/**
|
||||
* 手机
|
||||
*/
|
||||
const PAY_CLIENT_MOBILE = 2;
|
||||
|
||||
/**
|
||||
* 通用
|
||||
*/
|
||||
const PAY_CLIENT_ALL = 3;
|
||||
|
||||
public static function getMethodMap()
|
||||
{
|
||||
return [
|
||||
self::METHOD_JUMP => admin_trans('pay.fields.method_jump'),
|
||||
self::METHOD_SCAN => admin_trans('pay.fields.method_scan'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getClientMap()
|
||||
{
|
||||
return [
|
||||
self::PAY_CLIENT_PC => admin_trans('pay.fields.pay_client_pc'),
|
||||
self::PAY_CLIENT_MOBILE => admin_trans('pay.fields.pay_client_mobile'),
|
||||
self::PAY_CLIENT_ALL => admin_trans('pay.fields.pay_client_all'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user