diff --git a/app/Admin/Actions/Grid/GoodsNewImage.php b/app/Admin/Actions/Grid/GoodsNewImage.php new file mode 100644 index 0000000..3a3f771 --- /dev/null +++ b/app/Admin/Actions/Grid/GoodsNewImage.php @@ -0,0 +1,36 @@ +getKey(); + + $modal = Modal::make() + ->xl() + ->title($this->title) + ->body(GoodsNewImageForm::make()->setKey($id)) + ->button($this->title); + + return $modal; + } + + public function parameters() + { + + return [ + + ]; + } +} diff --git a/app/Admin/Controllers/v3/GoodsNewController.php b/app/Admin/Controllers/v3/GoodsNewController.php index dce3f92..04626e1 100644 --- a/app/Admin/Controllers/v3/GoodsNewController.php +++ b/app/Admin/Controllers/v3/GoodsNewController.php @@ -3,6 +3,7 @@ namespace App\Admin\Controllers\v3; use App\Admin\Actions\Grid\GoodsNewCopy; +use App\Admin\Actions\Grid\GoodsNewImage; use App\Admin\Repositories\v3\GoodsNew; use Dcat\Admin\Form; use Dcat\Admin\Grid; @@ -62,7 +63,7 @@ class GoodsNewController extends AdminController $grid->sort->sortable(); $grid->on_sale->switch(); - $grid->actions([new GoodsNewCopy()]); + $grid->actions([new GoodsNewCopy(),new GoodsNewImage()]); $grid->filter(function (Grid\Filter $filter) use($storeList, $categoryList, $goodsCategoryList, $marketList){ $filter->like('name'); $filter->equal('store_id')->select($storeList); @@ -228,13 +229,25 @@ class GoodsNewController extends AdminController $form->disableEditingCheck(); $form->disableCreatingCheck(); }); - // $form->saving(function (Form $form){ + $form->saving(function (Form $form){ // $storeId = $form->input('store_id'); // 商品所属市场,根据店铺查询市场 // $info = StoreModel::getStoreInfo($storeId,'market_id'); // $form->market_id = $info->market_id; - // }); + + $tags = $form->input('tags'); + $tagsArr = []; + foreach($tags as $kt => $tag){ + if(empty($tag)){ + unset($tags[$kt]); + continue; + } + $tagsArr[] = $tag; + } + + $form->tags = json_encode($tagsArr); + }); }); } diff --git a/app/Admin/Forms/GoodsNewImageForm.php b/app/Admin/Forms/GoodsNewImageForm.php new file mode 100644 index 0000000..2f0bbd1 --- /dev/null +++ b/app/Admin/Forms/GoodsNewImageForm.php @@ -0,0 +1,105 @@ +get(); + $markets = StoreModel::whereIn('id',$storeIds)->pluck('market_id','id'); + foreach($storeIds as $key =>$value){ + $storeId = $value; + $model = new GoodsModel(); + + $model->store_id = $storeId; + $model->market_id = $markets[$storeId]; + $model->category_id = $goods->category_id; + + $model->name = $goods->name; + $model->cover_img = $goods->cover_img; + $model->goods_unit = $goods->goods_unit; + + $model->tags = $goods->tags; + $model->spec = $goods->spec; + $model->details_imgs = $goods->details_imgs; + $model->content = $goods->content; + $model->details = $goods->details; + + $model->price = $goods->price; + $model->original_price = $goods->original_price; + $model->vip_price = $goods->vip_price; + + $model->start_num = $goods->start_num; + $model->restrict_num = $goods->restrict_num; + $model->is_infinite = $goods->is_infinite; + $model->inventory = $goods->inventory; + + $model->on_sale = $goods->on_sale; + $model->sort = $goods->sort; + $model->remark = $goods->remark; + + if($model->save() && !empty($goodsBanners)){ + $goodsId = $model->getKey(); + $banners = []; + foreach($goodsBanners as $kb => $vb){ + $banners[] = [ + 'goods_id' => $goodsId, + 'type' => $vb->type, + 'path' => $vb->path, + 'sort' => $vb->sort, + 'created_at' => time(), + 'updated_at' => time(), + ]; + GoodsBannerModel::insert($banners); + } + }; + } + + return $this->success('修改成功', '/goods'); + } + + /** + * Build a form here. + */ + public function form() + { + $id = $this->getKey(); + $goods = GoodsModel::select('name')->find($id); + $this->hidden('goods_id')->value($id); + $this->display('name')->value($goods->name); + $this->image('cover_img','封面图'); + $this->multipleImage('banners','轮播图'); + } + + /** + * The data of the form. + * + * @return array + */ + public function default() + { + return []; + } + +} diff --git a/app/Console/Commands/MigrateStoreAccount.php b/app/Console/Commands/MigrateStoreAccount.php new file mode 100644 index 0000000..f2ec97c --- /dev/null +++ b/app/Console/Commands/MigrateStoreAccount.php @@ -0,0 +1,163 @@ +['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; + } +} diff --git a/app/Models/v3/GoodsNew.php b/app/Models/v3/GoodsNew.php index 026e2b2..c0b6dfe 100644 --- a/app/Models/v3/GoodsNew.php +++ b/app/Models/v3/GoodsNew.php @@ -23,7 +23,7 @@ class GoodsNew extends Model protected $casts = [ 'details_imgs'=>'array', - 'tags'=>'array', + // 'tags'=>'array', 'spec'=>'array', ];