Browse Source
Merge branch 'hotfix-phoenix'
Merge branch 'hotfix-phoenix'
# Conflicts: # app/Console/Commands/MigrateStore.phpmaster
13 changed files with 288 additions and 373 deletions
-
39app/Admin/Actions/Grid/v3/CouponForbidden.php
-
42app/Admin/Actions/Grid/v3/CouponPublish.php
-
5app/Admin/Controllers/ImsCjdcMarketController.php
-
92app/Admin/Controllers/v3/CouponController.php
-
32app/Admin/Controllers/v3/StoreController.php
-
95app/Admin/Forms/v3/CouponPublishForm.php
-
139app/Console/Commands/MigrateCoupon.php
-
23app/Console/Commands/MigrateCouponReceive.php
-
2app/Console/Commands/MigrateCouponUse.php
-
80app/Console/Commands/MigrateFePrint.php
-
80app/Console/Commands/MigrateMarketData.php
-
8app/Models/v3/Coupon.php
-
24app/Models/v3/CouponReceiveType.php
@ -0,0 +1,39 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Actions\Grid\v3; |
||||
|
|
||||
|
use Dcat\Admin\Grid\RowAction; |
||||
|
use App\Models\v3\Coupon as CouponModel; |
||||
|
|
||||
|
class CouponForbidden extends RowAction |
||||
|
{ |
||||
|
/** |
||||
|
* @return string |
||||
|
*/ |
||||
|
protected $title = '禁用'; |
||||
|
|
||||
|
|
||||
|
public function handle() |
||||
|
{ |
||||
|
$id = $this->getKey(); |
||||
|
$coupon = CouponModel::getInfo($id); |
||||
|
if(!empty($coupon)){ |
||||
|
$coupon->status = 3; |
||||
|
if($coupon->save()){ |
||||
|
return $this->response()->success('禁用成功!','/coupon'); |
||||
|
} |
||||
|
} |
||||
|
return $this->response()->success('禁用失败!'); |
||||
|
} |
||||
|
|
||||
|
// 确认弹窗信息
|
||||
|
public function confirm() |
||||
|
{ |
||||
|
return '您确定要禁用吗?'; |
||||
|
} |
||||
|
|
||||
|
public function parameters() |
||||
|
{ |
||||
|
return ['status'=>3]; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Actions\Grid\v3; |
||||
|
|
||||
|
use Dcat\Admin\Grid\RowAction; |
||||
|
use Dcat\Admin\Widgets\Modal; |
||||
|
use App\Admin\Forms\v3\CouponPublishForm; |
||||
|
|
||||
|
class CouponPublish extends RowAction |
||||
|
{ |
||||
|
/** |
||||
|
* @return string |
||||
|
*/ |
||||
|
protected $title = '发布'; |
||||
|
|
||||
|
public function render() |
||||
|
{ |
||||
|
$id = $this->getKey(); |
||||
|
|
||||
|
$modal = Modal::make() |
||||
|
->xl() |
||||
|
->title($this->title) |
||||
|
->body(CouponPublishForm::make()->setKey($id)) |
||||
|
->button($this->title); |
||||
|
|
||||
|
return $modal; |
||||
|
} |
||||
|
|
||||
|
// 确认弹窗信息
|
||||
|
public function confirm() |
||||
|
{ |
||||
|
return '您确定要发布吗?'; |
||||
|
} |
||||
|
|
||||
|
public function parameters() |
||||
|
{ |
||||
|
|
||||
|
return [ |
||||
|
|
||||
|
]; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,95 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Forms\v3; |
||||
|
|
||||
|
use App\Models\v3\GoodsBanners; |
||||
|
use Dcat\Admin\Widgets\Form; |
||||
|
use Symfony\Component\HttpFoundation\Response; |
||||
|
use App\Models\v3\CouponReceiveType as ReceiveTypeModel; |
||||
|
use App\Models\v3\CouponSetting as SettingModel; |
||||
|
use App\Models\v3\Coupon as CouponModel; |
||||
|
|
||||
|
class CouponPublishForm extends Form |
||||
|
{ |
||||
|
|
||||
|
/** |
||||
|
* Handle the form request. |
||||
|
* |
||||
|
* @param array $input |
||||
|
* |
||||
|
* @return Response |
||||
|
*/ |
||||
|
public function handle(array $input) |
||||
|
{ |
||||
|
// 获取外部传递参数
|
||||
|
$id = $input['id']; |
||||
|
$receiveType = $input['receive_type']; |
||||
|
|
||||
|
$coupon = CouponModel::find($id); |
||||
|
if(!$coupon){ |
||||
|
return $this->error('优惠券不存在或已删除!'); |
||||
|
} |
||||
|
|
||||
|
switch($coupon->status){ |
||||
|
case 0: |
||||
|
case 3: |
||||
|
// 判断活动时间 还未判断
|
||||
|
|
||||
|
$coupon->status = 1; |
||||
|
if(!$coupon->save()){ |
||||
|
return $this->error('发布失败!'); |
||||
|
} |
||||
|
// 删除领取方式
|
||||
|
$delRes = ReceiveTypeModel::where('coupon_id',$id)->delete(); |
||||
|
if($delRes === false){ |
||||
|
return $this->error('发布失败!'); |
||||
|
} |
||||
|
// 添加领取方式
|
||||
|
$receiveModel = new ReceiveTypeModel(); |
||||
|
$receiveModel->coupon_id = $id; |
||||
|
$receiveModel->receive_type = $receiveType; |
||||
|
// 获取一次可领取数量
|
||||
|
$receiveNumber = SettingModel::getSettingInfo($receiveType,'value'); |
||||
|
$receiveModel->one_receive_number = empty($receiveNumber) ? 1 : $receiveNumber->value; |
||||
|
|
||||
|
if($receiveModel->save()){ |
||||
|
return $this->success('发布成功','/coupon'); |
||||
|
} |
||||
|
break; |
||||
|
case 1: |
||||
|
return $this->error('优惠券已发布!'); |
||||
|
break; |
||||
|
case 2: |
||||
|
return $this->error('优惠券已领完!'); |
||||
|
break; |
||||
|
case -1: |
||||
|
return $this->error('优惠券已删除!'); |
||||
|
break; |
||||
|
} |
||||
|
return $this->error('发布失败!'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Build a form here. |
||||
|
*/ |
||||
|
public function form() |
||||
|
{ |
||||
|
$id = $this->getKey(); |
||||
|
$receiveTypeInfo = ReceiveTypeModel::getReceiveTypeInfo($id,'receive_type'); |
||||
|
$list = SettingModel::getSettingArray(); |
||||
|
$receiveType = empty($receiveTypeInfo->receive_type)? 0 :$receiveTypeInfo->receive_type; |
||||
|
$this->hidden('id')->value($id); |
||||
|
$this->select('receive_type','领取方式')->required()->options($list)->value($receiveType); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* The data of the form. |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function default() |
||||
|
{ |
||||
|
return []; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -1,139 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Console\Commands; |
|
||||
|
|
||||
use Illuminate\Console\Command; |
|
||||
use Illuminate\Support\Facades\DB; |
|
||||
use Illuminate\Support\Facades\Schema; |
|
||||
|
|
||||
class MigrateCoupon extends Command |
|
||||
{ |
|
||||
/** |
|
||||
* The name and signature of the console command. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $signature = 'migrateData:coupon'; |
|
||||
|
|
||||
/** |
|
||||
* The console command description. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $description = 'migrate 迁移优惠券数据'; |
|
||||
|
|
||||
/** |
|
||||
* Create a new command instance. |
|
||||
* |
|
||||
* @return void |
|
||||
*/ |
|
||||
public function __construct() |
|
||||
{ |
|
||||
parent::__construct(); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Execute the console command. |
|
||||
* |
|
||||
* @return int |
|
||||
*/ |
|
||||
public function handle() |
|
||||
{ |
|
||||
$oldSetTableName = 'ims_system_coupon_setting'; |
|
||||
$oldTableName = 'ims_system_coupon_user'; |
|
||||
$oldTypeTableName = 'ims_system_coupon_user_receivetype'; |
|
||||
$newSetTableName = 'lanzu_coupon_setting'; |
|
||||
$newTableName = 'lanzu_coupon'; |
|
||||
$newTypeTableName = 'lanzu_coupon_receive_type'; |
|
||||
|
|
||||
// 判断表是否存在
|
|
||||
if(!Schema::hasTable($oldTableName)){ |
|
||||
var_dump('旧表不存在'); |
|
||||
return 0; |
|
||||
} |
|
||||
if(!Schema::hasTable($newTableName)){ |
|
||||
var_dump('新表不存在'); |
|
||||
return 0; |
|
||||
} |
|
||||
$oldSetData = DB::table($oldSetTableName)->get(); |
|
||||
$oldData = DB::table($oldTableName)->get(); |
|
||||
$oldTypeData = DB::table($oldTypeTableName)->get(); |
|
||||
$bar = $this->output->createProgressBar(count($oldData)); |
|
||||
$bar->start(); |
|
||||
|
|
||||
$newSetData = []; |
|
||||
$newData = []; |
|
||||
$newTypeData = []; |
|
||||
foreach ($oldSetData as $key => $value) { |
|
||||
$newSetData[] = [ |
|
||||
'id' => $value->id, |
|
||||
'name' => $value->name ?? 0, |
|
||||
'category' => $value->category ?? 0, |
|
||||
'value' => $value->value ?? 0, |
|
||||
'desc' => $value->desc ?? '', |
|
||||
'sort' => $value->sort ?? 0, |
|
||||
'status' => $value->status ?? 0, |
|
||||
|
|
||||
'created_at' => time(), |
|
||||
'updated_at' => time(), |
|
||||
]; |
|
||||
} |
|
||||
foreach ($oldData as $key => $value) { |
|
||||
$newData[] = [ |
|
||||
'id' => $value->id, |
|
||||
'status' => $value->status ?? 0, |
|
||||
'active_type' => $value->active_type ?? 0, |
|
||||
'type' => $value->type ?? 0, |
|
||||
'title' => $value->title ?? '', |
|
||||
'introduce' => $value->introduce ?? '', |
|
||||
'start_time' => $value->start_time ?? 0, |
|
||||
'end_time' => $value->end_time, |
|
||||
'full_amount' => $value->full_amount, |
|
||||
'discounts' => $value->discounts ?? 0, |
|
||||
'is_new_user' => $value->is_new_user ?? 0, |
|
||||
|
|
||||
'inventory' => $value->inventory, |
|
||||
'inventory_use' => $value->inventory_use ?? 0, |
|
||||
'market_ids' => json_encode([]), |
|
||||
'category_ids' => json_encode([]), |
|
||||
'category' => $value->category ?? 0, |
|
||||
'discount_type' => $value->discount_type ?? 0, |
|
||||
'activity_available' => json_encode([]), |
|
||||
'weigh' => $value->weigh ?? 0, |
|
||||
'usable_number' => $value->usable_number ?? 0, |
|
||||
'usable_start_time' => $value->usable_start_time ?? 0, |
|
||||
'usable_end_time' => $value->usable_end_time ?? 0, |
|
||||
|
|
||||
'remark' => $value->remark ?? 0, |
|
||||
'add_user_id' => $value->add_user_id ?? 0, |
|
||||
'update_user_id' => $value->update_user_id ?? 0, |
|
||||
'tags' => json_encode([]), |
|
||||
|
|
||||
'created_at' => $value->addtime ?? 0, |
|
||||
'updated_at' => time(), |
|
||||
'deleted_at' => $value->status == -1 ? time() : $value->deleted_at ?? null, |
|
||||
]; |
|
||||
} |
|
||||
foreach ($oldTypeData as $key => $value) { |
|
||||
$newTypeData[] = [ |
|
||||
'id' => $value->id, |
|
||||
'coupon_id' => $value->system_coupon_user_id ?? 0, |
|
||||
|
|
||||
'receive_type' => $value->receive_type ?? 0, |
|
||||
'one_receive_number' => $value->one_receive_number ?? 0, |
|
||||
|
|
||||
'created_at' => $value->add_time ?? 0, |
|
||||
'updated_at' => time(), |
|
||||
]; |
|
||||
$bar->advance(); |
|
||||
} |
|
||||
|
|
||||
// insert new data to new table
|
|
||||
DB::table($newSetTableName)->insert($newSetData); |
|
||||
DB::table($newTableName)->insert($newData); |
|
||||
DB::table($newTypeTableName)->insert($newTypeData); |
|
||||
|
|
||||
$bar->finish(); |
|
||||
return 0; |
|
||||
} |
|
||||
} |
|
||||
@ -1,80 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Console\Commands; |
|
||||
|
|
||||
use Illuminate\Console\Command; |
|
||||
use Illuminate\Support\Facades\DB; |
|
||||
use Illuminate\Support\Facades\Schema; |
|
||||
|
|
||||
class MigrateFePrint extends Command |
|
||||
{ |
|
||||
/** |
|
||||
* The name and signature of the console command. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $signature = 'migrateData:fePrint'; |
|
||||
|
|
||||
/** |
|
||||
* The console command description. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $description = 'migrate 迁移打印机数据'; |
|
||||
|
|
||||
/** |
|
||||
* Create a new command instance. |
|
||||
* |
|
||||
* @return void |
|
||||
*/ |
|
||||
public function __construct() |
|
||||
{ |
|
||||
parent::__construct(); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Execute the console command. |
|
||||
* |
|
||||
* @return int |
|
||||
*/ |
|
||||
public function handle() |
|
||||
{ |
|
||||
$oldTableName = 'ims_cjdc_feprint'; |
|
||||
$newTableName = 'lanzu_feprint'; |
|
||||
// 判断表是否存在
|
|
||||
if(!Schema::hasTable($oldTableName)){ |
|
||||
var_dump('旧表不存在'); |
|
||||
return 0; |
|
||||
} |
|
||||
if(!Schema::hasTable($newTableName)){ |
|
||||
var_dump('新表不存在'); |
|
||||
return 0; |
|
||||
} |
|
||||
$oldData = DB::table($oldTableName)->get(); |
|
||||
|
|
||||
$bar = $this->output->createProgressBar(count($oldData)); |
|
||||
$bar->start(); |
|
||||
$newData = []; |
|
||||
foreach ($oldData as $key => $value) { |
|
||||
$newData[] = [ |
|
||||
'id' => $value->id, |
|
||||
'name' => $value->name ?? '', |
|
||||
'sn' => $value->sn ?? '', |
|
||||
'market_id' => $value->market_id ?? 0, |
|
||||
'simnum' => $value->simnum ?? 0 , |
|
||||
'addtime' => $value->addtime ?? 0, |
|
||||
'status' => $value->status ?? 0, |
|
||||
|
|
||||
'created_at' => $value->addtime ? strtotime($value->addtime) : 0, |
|
||||
'updated_at' => time(), |
|
||||
]; |
|
||||
|
|
||||
$bar->advance(); |
|
||||
} |
|
||||
|
|
||||
DB::table($newTableName)->insert($newData); |
|
||||
|
|
||||
$bar->finish(); |
|
||||
return 0; |
|
||||
} |
|
||||
} |
|
||||
@ -1,80 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Console\Commands; |
|
||||
|
|
||||
use Illuminate\Console\Command; |
|
||||
use Illuminate\Support\Facades\DB; |
|
||||
|
|
||||
class MigrateMarketData extends Command |
|
||||
{ |
|
||||
/** |
|
||||
* The name and signature of the console command. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $signature = 'migrateData:market'; |
|
||||
|
|
||||
/** |
|
||||
* The console command description. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $description = 'migrate market data'; |
|
||||
|
|
||||
/** |
|
||||
* Create a new command instance. |
|
||||
* |
|
||||
* @return void |
|
||||
*/ |
|
||||
public function __construct() |
|
||||
{ |
|
||||
parent::__construct(); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Execute the console command. |
|
||||
* |
|
||||
* @return int |
|
||||
*/ |
|
||||
public function handle() |
|
||||
{ |
|
||||
|
|
||||
// get old data from old table
|
|
||||
$oldData = DB::table('ims_cjdc_market')->get(); |
|
||||
|
|
||||
$bar = $this->output->createProgressBar(count($oldData)); |
|
||||
$bar->start(); |
|
||||
|
|
||||
$newData = []; |
|
||||
foreach ($oldData as $key => $value) { |
|
||||
$coordinates = explode(',', $value->coordinates); |
|
||||
$newData[] = [ |
|
||||
'id' => $value->id, |
|
||||
'mp_id' => $value->mp_id ?? 0, |
|
||||
'name' => $value->name ?? '', |
|
||||
'logo' => $value->logo ?? '', |
|
||||
'introduce' => $value->introduce ?? '', |
|
||||
'imgs' => $value->imgs ?? '', |
|
||||
'province_id' => 2162, |
|
||||
'city_id' => 2163, |
|
||||
'region_id' => 0, |
|
||||
'address' => $value->address ?? '', |
|
||||
'tel' => $value->tel ?? '', |
|
||||
'lat' => $coordinates[0] ?? '', |
|
||||
'lng' => $coordinates[1] ?? '', |
|
||||
'status' => $value->status ?? 1, |
|
||||
'sort' => $value->sort ?? 1, |
|
||||
'created_at' => $value->addtime ? strtotime($value->addtime) : 0, |
|
||||
'updated_at' => time(), |
|
||||
]; |
|
||||
|
|
||||
$bar->advance(); |
|
||||
} |
|
||||
|
|
||||
// insert new data to new table
|
|
||||
DB::table('lanzu_market')->insert($newData); |
|
||||
|
|
||||
$bar->finish(); |
|
||||
return 0; |
|
||||
} |
|
||||
} |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue