7 changed files with 299 additions and 5 deletions
-
36app/Admin/Actions/Grid/GoodsNewImage.php
-
10app/Admin/Controllers/v3/GoodsController.php
-
19app/Admin/Controllers/v3/GoodsNewController.php
-
72app/Admin/Forms/GoodsNewImageForm.php
-
163app/Console/Commands/MigrateStoreAccount.php
-
2app/Models/v3/Goods.php
-
2app/Models/v3/GoodsNew.php
@ -0,0 +1,36 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Actions\Grid; |
|||
|
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Dcat\Admin\Widgets\Modal; |
|||
use App\Admin\Forms\GoodsNewImageForm; |
|||
|
|||
class GoodsNewImage extends RowAction |
|||
{ |
|||
/** |
|||
* @return string |
|||
*/ |
|||
protected $title = '上传图片'; |
|||
|
|||
public function render() |
|||
{ |
|||
$id = $this->getKey(); |
|||
|
|||
$modal = Modal::make() |
|||
->xl() |
|||
->title($this->title) |
|||
->body(GoodsNewImageForm::make()->setKey($id)) |
|||
->button($this->title); |
|||
|
|||
return $modal; |
|||
} |
|||
|
|||
public function parameters() |
|||
{ |
|||
|
|||
return [ |
|||
|
|||
]; |
|||
} |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Forms; |
|||
|
|||
use App\Models\v3\GoodsBanners; |
|||
use Dcat\Admin\Widgets\Form; |
|||
use Symfony\Component\HttpFoundation\Response; |
|||
use App\Models\v3\GoodsNew as GoodsModel; |
|||
use App\Models\v3\GoodsNewBanners as GoodsBannerModel; |
|||
use Illuminate\Support\Facades\DB; |
|||
|
|||
class GoodsNewImageForm extends Form |
|||
{ |
|||
|
|||
/** |
|||
* Handle the form request. |
|||
* |
|||
* @param array $input |
|||
* |
|||
* @return Response |
|||
*/ |
|||
public function handle(array $input) |
|||
{ |
|||
// 获取外部传递参数
|
|||
$goodsId = $input['goods_id']; |
|||
$coverImg= $input['cover_img']; |
|||
$bannerImg= $input['img_banner']; |
|||
|
|||
if($goodsId > 0 && !empty($coverImg)){ |
|||
$data = ['cover_img' => $coverImg]; |
|||
GoodsModel::where('id',$goodsId)->update($data); |
|||
} |
|||
if($goodsId > 0 && !empty($bannerImg)){ |
|||
$banner = GoodsBannerModel::where('goods_id',$goodsId)->first(); |
|||
if(empty($banner)){ |
|||
$banner = new GoodsBanners(); |
|||
$banner->goods_id = $goodsId; |
|||
$banner->type = 1; |
|||
$banner->created_at = time(); |
|||
} |
|||
$banner->path = $bannerImg; |
|||
$banner->updated_at = time(); |
|||
$banner->save(); |
|||
} |
|||
|
|||
return $this->success('修改成功', '/goods_new'); |
|||
} |
|||
|
|||
/** |
|||
* Build a form here. |
|||
*/ |
|||
public function form() |
|||
{ |
|||
$id = $this->getKey(); |
|||
$goods = GoodsModel::select('name')->find($id); |
|||
$goodName = empty($goods->name)?'':$goods->name; |
|||
$this->hidden('goods_id')->value($id); |
|||
$this->image('cover_img','封面图')->url('ops/files')->help('商品名称:'.$goodName); |
|||
$this->image('img_banner','轮播图')->url('ops/files'); |
|||
} |
|||
|
|||
/** |
|||
* The data of the form. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function default() |
|||
{ |
|||
return []; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,163 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use Illuminate\Support\Facades\DB; |
|||
use Illuminate\Support\Facades\Schema; |
|||
|
|||
class MigrateStoreAccount extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'migrateData:storeAccount'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'Command 迁移商户流水数据'; |
|||
|
|||
/** |
|||
* Create a new command instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* |
|||
* @return int |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
$m = ['120'=>['sort'=>'12'],'12'=>['sort'=>'3'],'112'=>['sort'=>'2'],'110'=>['sort'=>'120']]; |
|||
|
|||
|
|||
|
|||
var_dump($m); |
|||
return 0; |
|||
$oldTableName = 'ims_cjdc_store_account'; |
|||
$newTableName = 'lanzu_financial_record'; |
|||
// 判断表是否存在
|
|||
if(!Schema::hasTable($oldTableName)){ |
|||
var_dump('旧表不存在'); |
|||
return 0; |
|||
} |
|||
if(!Schema::hasTable($newTableName)){ |
|||
var_dump('新表不存在'); |
|||
return 0; |
|||
} |
|||
|
|||
$desc='用户店铺首单奖励'; |
|||
$comment='用户当面付商户奖励'; |
|||
|
|||
$desc='新用户下单奖励'; |
|||
$comment='用户当面付商户奖励'; |
|||
|
|||
$desc = '线上外卖订单收入'; |
|||
$comment = '用户订单完成'; |
|||
|
|||
$desc = '线下当面付订单收入'; |
|||
$comment = '用户订单完成'; |
|||
|
|||
$desc = '线上订单退款'; |
|||
$comment = '线上订单退款到微信'; |
|||
|
|||
$desc = '商户提现'; |
|||
$comment = '商户提现打款'; |
|||
|
|||
$oldData = DB::table($oldTableName)->orderBy('id','asc')->get(); |
|||
$bar = $this->output->createProgressBar(count($oldData)); |
|||
$bar->start(); |
|||
$startTime = time(); |
|||
$error = []; |
|||
foreach ($oldData as $key => $value){ |
|||
$storeId = $value->store_id; |
|||
$userId = $value->user_id; |
|||
if(empty($userId)){ |
|||
$error[] = ['id'=>$userId]; |
|||
break; |
|||
} |
|||
|
|||
// 判断是否存在 总账
|
|||
$exist = DB::table($newTableName) |
|||
->where('user_id',$userId) |
|||
->where('user_type',5) |
|||
->where('source_id',$value->order_id) |
|||
->where('source_type',0) |
|||
->where('money_type') |
|||
->exists(); |
|||
|
|||
if(!$exist){ |
|||
$newData =[ |
|||
'id'=>$userId, |
|||
'nick_name'=>$value->name, |
|||
|
|||
'avatar'=>$value->img, |
|||
'openid'=>$value->openid, |
|||
|
|||
'total_score'=>$value->total_score, |
|||
'wallet'=>$value->wallet, |
|||
|
|||
'real_name'=>$value->user_name, |
|||
'tel'=>$value->user_tel, |
|||
'unionid'=>$value->unionid, |
|||
|
|||
'created_at' => strtotime($value->join_time), |
|||
'updated_at' => $value->updated_at, |
|||
]; |
|||
|
|||
$res = DB::table($newTableName)->insert($newData); |
|||
if(!$res){ |
|||
$error[] = ['id'=>$userId]; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
// 判断是否存在 详细账
|
|||
$mod = bcmod((string)$userId, '5', 0); |
|||
$newSubTableName = $newTableName.'_'.$mod; |
|||
$existSub = DB::table($newSubTableName)->where('id',$userId)->exists(); |
|||
if(!$existSub){ |
|||
$newData =[ |
|||
'id'=>$userId, |
|||
'nick_name'=>$value->name, |
|||
|
|||
'avatar'=>$value->img, |
|||
'openid'=>$value->openid, |
|||
|
|||
'total_score'=>$value->total_score, |
|||
'wallet'=>$value->wallet, |
|||
|
|||
'real_name'=>$value->user_name, |
|||
'tel'=>$value->user_tel, |
|||
'unionid'=>$value->unionid, |
|||
|
|||
'created_at' => strtotime($value->join_time), |
|||
'updated_at' => $value->updated_at, |
|||
]; |
|||
|
|||
$res = DB::table($newSubTableName)->insert($newData); |
|||
if(!$res){ |
|||
$error[] = ['id'=>$userId]; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
$bar->advance(); |
|||
} |
|||
$bar->finish(); |
|||
var_dump([time()-$startTime]); |
|||
var_dump($error); |
|||
return 0; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue