创建版本

This commit is contained in:
2021-02-22 12:17:00 +08:00
commit af555f49c3
2332 changed files with 369202 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
<?php namespace Gdoo\Promotion\Models;
use Gdoo\Index\Models\BaseModel;
class Promotion extends BaseModel
{
protected $table = 'promotion';
public static $tabs = [
'name' => 'tab',
'items' => [
['value' => 'promotion', 'url' => 'promotion/promotion/index', 'name' => '促销列表'],
]
];
public static $bys = [
'name' => 'by',
'items' => [
['value' => '', 'name' => '全部'],
['value' => 'divider'],
['value' => 'day', 'name' => '今日创建'],
['value' => 'week', 'name' => '本周创建'],
['value' => 'month', 'name' => '本月创建'],
]
];
public function customer()
{
return $this->belongsTo('Gdoo\Customer\Models\Customer');
}
public function datas()
{
return $this->hasMany('Gdoo\Promotion\Models\PromotionData');
}
public function cashs()
{
return $this->hasMany('Gdoo\Promotion\Models\PromotionCash');
}
public static $materials = [
['id' => 0, 'name' => '待审核', 'color' => 'default'],
['id' => 1, 'name' => '不合格', 'color' => 'info'],
['id' => 2, 'name' => '已审核', 'color' => 'success']
];
public static $cashs = [
['id' => 1, 'name' => '现配', 'color' => 'default'],
['id' => 2, 'name' => '凭兑', 'color' => 'info'],
];
public static $status = [
['id' => 0, 'name' => '待审', 'color' => 'default'],
['id' => 1, 'name' => '已审', 'color' => 'info'],
];
public function scopeDialog($q, $value)
{
return $q->whereIn('id', $value)->pluck('sn', 'id');
}
}
@@ -0,0 +1,50 @@
<?php namespace Gdoo\Promotion\Models;
use DB;
use Gdoo\Index\Models\BaseModel;
use Gdoo\Promotion\Models\Promotion;
use Gdoo\Promotion\Models\PromotionCashData;
class PromotionCash extends BaseModel
{
protected $table = 'promotion_cash';
public function datas()
{
return $this->hasMany(PromotionCashData::class, 'cash_id');
}
public function promotion()
{
return $this->belongsTo(Promotion::class);
}
// 促销兑现单生成客户订单
public function makeCustomerOrder($cashId)
{
// 客户订单数
$cash = PromotionCash::with('datas')->find($cashId);
$total_num = DB::table('order')->count('id');
$master['customer_id'] = $cash->promotion->customer_id;
$master['flow_step_id'] = 1;
$master['number'] = 'CXDX-'.date('Y-m').'-'.($total_num + 1);
$master['add_time'] = time();
$orderId = DB::table('order')->insertGetId($master);
foreach ($cash->datas as $data) {
$row = [
'order_id' => $orderId,
'customer_id' => $cash->promotion->customer_id,
'product_id' => $data['product_id'],
'price' => $data['price'],
'amount' => $data['quantity'],
'type' => $data['type_id'],
'content' => $data['remark'],
];
DB::table('order_data')->insert($row);
}
return true;
}
}
@@ -0,0 +1,14 @@
<?php namespace Gdoo\Promotion\Models;
use Gdoo\Index\Models\BaseModel;
use Gdoo\Promotion\Models\PromotionCash;
class PromotionCashData extends BaseModel
{
protected $table = 'promotion_cash_data';
public function cash()
{
return $this->belongsTo(PromotionCash::class);
}
}
@@ -0,0 +1,8 @@
<?php namespace Gdoo\Promotion\Models;
use Gdoo\Index\Models\BaseModel;
class PromotionData extends BaseModel
{
protected $table = 'promotion_data';
}
@@ -0,0 +1,36 @@
<?php namespace Gdoo\Promotion\Models;
use Gdoo\Index\Models\BaseModel;
class PromotionMaterial extends BaseModel
{
protected $table = 'promotion_material';
public static $tabs = [
'name' => 'tab',
'items' => [
['value' => 'promotion', 'url' => 'promotion/material/index', 'name' => '资料列表'],
]
];
public static $bys = [
'name' => 'by',
'items' => [
['value' => '-1', 'name' => '全部'],
['value' => 'divider'],
['value' => 'day', 'name' => '今日创建'],
['value' => 'week', 'name' => '本周创建'],
['value' => 'month', 'name' => '本月创建'],
]
];
public function promotion()
{
return $this->belongsTo('Gdoo\Promotion\Models\Promotion');
}
public function contact()
{
return $this->belongsTo('Gdoo\Customer\Models\Contact');
}
}
@@ -0,0 +1,26 @@
<?php namespace Gdoo\Promotion\Models;
use Gdoo\Index\Models\BaseModel;
class PromotionReview extends BaseModel
{
protected $table = 'promotion_review';
public static $tabs = [
'name' => 'tab',
'items' => [
['value' => 'review', 'url' => 'promotion/review/index', 'name' => '促销核销'],
]
];
public static $bys = [
'name' => 'by',
'items' => [
['value' => '', 'name' => '全部'],
['value' => 'divider'],
['value' => 'day', 'name' => '今日创建'],
['value' => 'week', 'name' => '本周创建'],
['value' => 'month', 'name' => '本月创建'],
]
];
}