添加:视频分享插件

This commit is contained in:
wuhui_zzw 2023-09-26 15:21:31 +08:00
parent 6c0161cbd0
commit ac10986a65
76 changed files with 11479 additions and 0 deletions

View File

@ -0,0 +1 @@
init

View File

@ -0,0 +1,101 @@
#app {
margin-bottom: 60px;
}
.vue-page {
border-radius: 5px;
width: calc(100% - 266px);
float: right;
margin-right: 10px;
position: fixed;
bottom: 0;
right: 0;
padding: 15px 5% 15px 0;
background: #fff;
height: 60px;
z-index: 999;
margin-top: 0;
box-shadow: 0 2px 9px rgba(51, 51, 51, 0.1);
}
.commit-title {
padding: 15px 0;
padding-bottom: 10px;
line-height: 30px;
border-bottom: solid 1px #eee;
color: #333;
margin-bottom: 25px;
}
.video-style {
height: 60px;
width: 60px;
object-fit: fill;
border-radius: inherit;
}
.img-style {
width: 50px;
height: 50px;
border-radius: 50%;
}
.space-li {
color: #ff9b45;
margin-left: 20px;
cursor: pointer;
}
.commit-title .el-button {
margin-left: 20px;
}
.commit-box {
margin: 0 0 100px 80px;
}
.commit-box .commit-detail .parent-text , .son-text {
display: flex;
margin-bottom: 10px;
}
.son-text {
margin: 20px 50px;
}
img {
height: 40px;
width: 40px;
border-radius: 50%;
}
.right-text {
margin-left: 10px;
}
.member-detail .el-icon-delete {
margin-left: 30px;
}
.time {
margin: 5px 0;
}
.color-bg {
color: #a4a4a4;
font-weight: 500;
}
.stow {
margin: 10px 0;
cursor: pointer;
}
.replay-name {
color: #3C4858;
}
.parent-content {
margin-right: 40px;
}

View File

@ -0,0 +1,383 @@
.main-panel > .content {
padding: 0;
}
.main-panel {
margin-top: 42px;
}
#app {
padding-bottom: 40px;
}
.rightlist #app .rightlist-head {
line-height: 50px;
padding: 0 0 15px 0;
}
.rightlist {
background: #eff3f6;
margin-top: 10px;
margin-bottom: 20px;
padding-bottom: 20px;
}
.form-list {
padding-top: 30px;
background: #fff;
border-radius: 10px;
position: relative;
top: 10px;
margin-left: 10px;
width: calc(100% - 20px);
}
.table-list {
padding-top: 30px;
background: #fff;
border-radius: 10px;
margin-top: 20px;
margin-left: 10px;
width: calc(100% - 20px);
}
.table-option a {
font-size: 12px;
font-weight: 600;
color: #29ba9c;
padding: 10px 0;
}
/* .el-form-item__label{padding-right:30px;} */
.tip {
font-size: 12px;
color: #999;
font-weight: 500;
line-height: 24px;
}
.rightlist-head-con {
padding-right: 20px;
font-size: 16px;
color: #888;
}
.el-tag {
/* font-weight: 700;
font-size: 15px;
margin-bottom: 30px; */
}
/* 单选框边框颜色 */
.el-radio__inner {
border: 1px solid #eff3f6;
}
.el-icon-edit {
font-size: 16px;
padding: 0 15px;
color: #409eff;
cursor: pointer;
}
/* 滑块选择小白点 */
.el-switch.is-checked .el-switch__core::after {
left: 100%;
margin-left: -17px;
}
.el-switch__core::after {
content: "";
position: absolute;
top: 1px;
left: 1px;
border-radius: 100%;
transition: all 0.3s;
width: 16px;
height: 16px;
background-color: #fff;
}
.el-checkbox__label {
display: inline-block;
padding-left: 3px;
}
.el-checkbox.is-bordered + .el-checkbox.is-bordered {
margin-left: 0px;
}
.vue-page {
border-radius: 5px;
width: calc(100% - 266px);
float: right;
margin-right: 10px;
position: fixed;
bottom: 0;
right: 0;
padding: 15px 5% 15px 0;
background: #fff;
height: 60px;
z-index: 999;
margin-top: 0;
box-shadow: 0 2px 9px rgba(51, 51, 51, 0.1);
}
.vue-center {
text-align: center;
}
.loading-height {
height: 500px;
}
.el-checkbox.is-bordered.el-checkbox--mini {
margin: 0 0;
}
[v-cloak] {
display: none;
}
.all {
background: #eff3f6;
min-height: 100vh;
padding-top: 20px;
}
.vue-main {
background: #fff;
border-radius: 5px;
margin: 0 10px;
padding: 10px;
min-height: calc(100vh - 90px);
}
.vue-nav {
background: #fff;
border-radius: 5px;
margin: 0 10px;
padding: 10px;
}
.vue-head {
background: #fff;
border-radius: 5px;
margin: 0 10px;
padding: 10px;
margin-bottom: 15px;
}
.vue-crumbs {
margin: 0 20px;
font-size: 14px;
color: #333;
font-weight: 400;
padding-bottom: 10px;
line-height: 32px;
}
.vue-crumbs a {
color: #333;
}
.vue-crumbs a:hover {
color: #29ba9c;
}
.vue-main-title {
display: flex;
margin: 5px 0;
line-height: 28px;
font-size: 14px;
color: #333;
font-weight: 700;
}
.vue-main-title-left {
width: 4px;
height: 14px;
margin-top: 6px;
background: #29ba9c;
display: inline-block;
margin-right: 10px;
}
.vue-main-title-content {
font-size: 14px;
flex: 1;
}
.vue-main-title-button {
text-align: right;
flex:1;
}
.vue-main-form {
margin-top: 20px;
}
.vue-category-title {
padding: 15px;
border-bottom: 1px solid #ccc;
margin-bottom: 15px;
font-weight: 600;
font-size: 15px;
}
.el-link-edit {
border-right: 1px solid;
line-height: 16px;
}
.el-link-edit-start {
border-right: 1px solid;
padding-right: 20px;
line-height: 16px;
}
.el-link-edit-middle {
border-right: 1px solid;
padding: 0 20px;
line-height: 16px;
}
.el-link-edit-end {
border-right: 0px;
padding-left: 20px;
line-height: 16px;
}
/* 上传图片 */
.avatar-uploader .el-upload {
margin-top: 15px;
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #29ba9c;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
.avatar_box {
width: 80%;
height: 80%;
margin: 0 auto;
}
.avatar {
width: 50%;
height: 50%;
object-fit: cover;
}
.el-upload-tip {
width: 178px;
margin: 0;
padding: 0;
color: #999;
text-align: center;
}
input[type="file"] {
display: none;
}
.avatar-uploader-box {
position: relative;
margin-top: 20px;
width: 200px;
}
.el-icon-circle-close {
position: absolute;
top: 0;
right: 0;
color: #999;
}
/*弹窗上传图片*/
#upload-img {
}
#upload-img .avatar {
width: 100px;
height: 100px;
display: block;
}
#upload-img .avatar-uploader-box {
position: relative;
margin: 20px 0 0 10px;
width: 110px;
}
#upload-img .el-icon-circle-close {
position: absolute;
top: -7px;
right: 1px;
color: #999;
}
.imgList {
display: flex;
flex-wrap: wrap;
margin: 10px auto;
}
/* 辅助色 */
.vue-assist-color,
.el-link-assist,
.el-link:hover {
color: #ff9b19 !important;
}
/* 选中及未选图片样式 */
.upload-box:hover {
border-color: #29ba9c;
color: #29ba9c;
}
.upload-box {
width: 150px;
height: 150px;
display: flex;
cursor: pointer;
border: 1px dashed #dde2ee;
justify-content: center;
align-items: center;
border-radius: 5px;
}
.upload-boxed {
width: 150px;
height: 150px;
position: relative;
border-radius: 5px;
display: inline-block;
}
.upload-boxed-text {
position: absolute;
bottom: 0;
line-height: 32px;
color: #fff;
text-align: center;
width: 100%;
background: #000;
opacity: 0.7;
border-radius: 0px 0px 5px 5px;
}
.upload-boxed-text-clear {
position: absolute;
bottom: 0;
right:-70px;
cursor: pointer;
line-height: 32px;
color: #ee3939;
}
.upload-boxed-list {
display: flex;
position: relative;
border-radius: 5px;
flex-wrap: wrap;
}
.upload-boxed-list-a {
width: 150px;
height: 170px;
margin: 0 10px 5px 0;
position: relative;
}
.upload-boxed-list-a .el-icon-close {
position: absolute;
top: -5px;
right: -5px;
color: #fff;
background: #333;
border-radius: 50%;
cursor: pointer;
}
.vue-main-title-content a {
color: #333;
}
.vue-main-title-content a:hover {
color: #29ba9c;
}
.vue-ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.black {
color: #333;
}
.upload-box-member {
text-align: center;
font-weight: 600;
font-size: 16px;
}

View File

@ -0,0 +1,7 @@
<?php
return [
app\common\events\PluginWasEnabled::class => function ($plugins) {
\Artisan::call('migrate',['--path'=>'plugins/video-share/migrations','--force'=>true]);
}
];

View File

@ -0,0 +1,64 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateImsYzVideoShareGoodsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('yz_video_share_goods')) {
Schema::create('yz_video_share_goods',
function (Blueprint $table) {
$table->increments('id');
$table->integer('uniacid')
->nullable();
$table->integer('uid')
->nullable()->comment('会员ID');
$table->integer('goods_id')
->nullable()->comment('商品ID');
$table->text('title', 65535)
->nullable()->comment('发现标题');
$table->text('cover', 65535)
->nullable()->comment('发现视频封面地址');
$table->text('video', 65535)
->nullable()->comment('发现视频地址');
$table->integer('share_num')
->nullable()->comment('分享次数');
$table->integer('like_num')
->nullable()->comment('点赞次数');
$table->integer('status')
->nullable()->comment('显示状态1显示0不显示');
$table->decimal('order_price', 10)
->nullable()->comment('转化订单金额');
$table->decimal('amount_total', 10)
->nullable()->comment('奖励金额');
$table->integer('created_at')
->nullable();
$table->integer('updated_at')
->nullable();
$table->integer('deleted_at')
->nullable();
});
\Illuminate\Support\Facades\DB::statement("ALTER TABLE `" . app('db')->getTablePrefix() . "yz_video_share_goods` comment '视频分享--发现管理表'");
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('yz_video_share_goods');
}
}

View File

@ -0,0 +1,60 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateImsYzVideoShareBonusTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('yz_video_share_bonus')) {
Schema::create('yz_video_share_bonus',
function (Blueprint $table) {
$table->increments('id');
$table->integer('uniacid')
->nullable();
$table->integer('uid')
->nullable()->comment('会员ID');
$table->integer('vid')
->nullable()->comment('发现管理ID');
$table->integer('order_id')
->nullable()->comment('订单ID');
$table->decimal('ratio', 10)
->nullable()->comment('奖励比例');
$table->decimal('order_price', 10)
->nullable()->comment('订单金额');
$table->decimal('amount', 10)
->nullable()->comment('奖励金额');
$table->integer('status')
->nullable()->comment('结算状态:1已结算0未结算');
$table->string('create_month')
->nullable()->comment('奖励生成月份');
$table->integer('created_at')
->nullable();
$table->integer('updated_at')
->nullable();
$table->integer('deleted_at')
->nullable();
});
\Illuminate\Support\Facades\DB::statement("ALTER TABLE `" . app('db')->getTablePrefix() . "yz_video_share_bonus` comment '视频分享--分红记录表'");
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('yz_video_share_bonus');
}
}

View File

@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateImsYzVideoShareLikeLogTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('yz_video_share_like_log')) {
Schema::create('yz_video_share_like_log',
function (Blueprint $table) {
$table->increments('id');
$table->integer('uniacid')
->nullable();
$table->integer('uid')
->nullable()->comment('会员ID');
$table->integer('vid')
->nullable()->comment('发现管理ID');
$table->integer('created_at')
->nullable();
$table->integer('updated_at')
->nullable();
$table->integer('deleted_at')
->nullable();
});
\Illuminate\Support\Facades\DB::statement("ALTER TABLE `" . app('db')->getTablePrefix() . "yz_video_share_like_log` comment '视频分享--点赞记录表'");
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('yz_video_share_like_log');
}
}

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
class AddColumnsToImsYzVideoShareGoodsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasTable('yz_video_share_goods')) {
Schema::table('yz_video_share_goods',
function (Blueprint $table) {
if (!Schema::hasColumn('yz_video_share_goods', 'uniacid')) {
$table->integer('uniacid')->nullable();
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('yz_video_share_goods', function (Blueprint $table) {
$table->dropColumn('uniacid');
});
}
}

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
class AddColumnsToImsYzVideoShareBonusTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasTable('yz_video_share_bonus')) {
Schema::table('yz_video_share_bonus',
function (Blueprint $table) {
if (!Schema::hasColumn('yz_video_share_bonus', 'order_price')) {
$table->decimal('order_price', 10)
->nullable();
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('yz_video_share_bonus', function (Blueprint $table) {
$table->dropColumn('order_price');
});
}
}

View File

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddFileNameToImsYzVideoShareGoodsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasTable('yz_video_share_goods')) {
Schema::table('yz_video_share_goods',
function (Blueprint $table) {
if (!Schema::hasColumn('yz_video_share_goods', 'file_name')) {
$table->string('file_name')->nullable();
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('yz_video_share_goods', function (Blueprint $table) {
$table->dropColumn('file_name');
});
}
}

View File

@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateImsYzVideoShareWatchRecordTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('yz_video_share_watch_record')) {
Schema::create('yz_video_share_watch_record', function (Blueprint $table) {
$table->integer('id', true);
$table->integer('member_id')->nullable()->index('memberid')->comment('观看会员ID');
$table->integer('video_id')->nullable()->comment('发现管理ID');
$table->integer('created_at')->nullable();
$table->integer('updated_at')->nullable();
$table->integer('deleted_at')->nullable();
});
\Illuminate\Support\Facades\DB::statement("ALTER TABLE `" . app('db')->getTablePrefix() . "yz_video_share_watch_record` comment '视频分享--观看记录表'");
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
if (Schema::hasTable('yz_video_share_watch_record')) {
Schema::drop('yz_video_share_watch_record');
}
}
}

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateYzVideoShareCategory extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('yz_video_share_category')) {
Schema::create('yz_video_share_category', function (Blueprint $table) {
$table->increments('id');
$table->integer('uniacid')->nullable();
$table->integer('sort')->nullable()->comment("排序");
$table->string('name')->nullable()->comment("名称");
$table->tinyInteger("is_show")->nullable()->comment("是否显示 1-显示 2-隐藏");
$table->integer('created_at')->nullable();
$table->integer('updated_at')->nullable();
$table->integer('deleted_at')->nullable();
});
}
\Illuminate\Support\Facades\DB::statement("ALTER TABLE `".app('db')->getTablePrefix()."yz_video_share_category` comment '视频分享--分类'");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('yz_video_share_category');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddCategoryToYzVideoShareGoods extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasTable('yz_video_share_goods')) {
Schema::table('yz_video_share_goods',
function (Blueprint $table) {
if (!Schema::hasColumn('yz_video_share_goods', 'category_id')) {
$table->integer('category_id')->nullable()->comment("分类ID");
}
if (!Schema::hasColumn('yz_video_share_goods', 'is_recommend')) {
$table->integer('is_recommend')->nullable()->comment("推荐 0-关闭 1-开启");
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateYzVideoShareFollow extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('yz_video_share_follow')) {
Schema::create('yz_video_share_follow', function (Blueprint $table) {
$table->increments('id');
$table->integer('uniacid')->nullable();
$table->integer('member_id')->nullable()->comment("被关注的用户ID");
$table->integer('follow_member_id')->nullable()->comment("关注者的用户ID");
$table->integer('created_at')->nullable();
$table->integer('updated_at')->nullable();
$table->integer('deleted_at')->nullable();
});
}
\Illuminate\Support\Facades\DB::statement("ALTER TABLE `".app('db')->getTablePrefix()."yz_video_share_follow` comment '视频分享--关注'");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('yz_video_share_follow');
}
}

View File

@ -0,0 +1,49 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
class CreateImsYzVideoShareCommentTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('yz_video_share_comment')) {
Schema::create('yz_video_share_comment', function (Blueprint $table) {
$table->integer('id', true);
$table->integer('uniacid')->comment('公众号id');
$table->integer('video_id')->default(0)->index('idx_videoid');
$table->integer('uid')->default(0)->comment('会员id');
$table->string('nick_name', 50)->nullable()->comment('评论昵称');
$table->string('head_img_url')->nullable()->comment('评论头像');
$table->string('content')->default('')->comment('内容');
$table->text('images', 65535)->nullable()->comment('图片');
$table->integer('comment_id')->default(0)->comment('评论ID');
$table->integer('reply_id')->nullable()->comment('回答哪个会员ID');
$table->integer('reply_comment_id')->nullable()->comment('回答哪个评论');
$table->string('reply_name', 50)->nullable()->comment('回答哪个昵称');
$table->integer('support_num')->default(0)->comment('点赞数');
$table->tinyInteger('type')->default(2);
$table->integer('created_at')->nullable();
$table->integer('updated_at')->nullable();
});
}
DB::statement("ALTER TABLE `" . app('db')->getTablePrefix() . "yz_video_share_comment` comment '视频分享--评论表'");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('yz_video_share_comment');
}
}

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
class CreateImsYzVideoCommentSupportTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('yz_video_comment_support')) {
Schema::create('yz_video_comment_support', function (Blueprint $table) {
$table->integer('id', true);
$table->integer('uniacid')->comment('公众号id');
$table->integer('comment_id')->default(0)->index('idx_commentid');
$table->integer('member_id');
$table->tinyInteger('status')->default(1)->comment('-1:不点赞1:点赞');
$table->integer('created_at')->nullable();
$table->integer('updated_at')->nullable();
});
}
DB::statement("ALTER TABLE `" . app('db')->getTablePrefix() . "yz_video_comment_support` comment '视频分享--评论点赞表'");
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('yz_video_comment_support');
}
}

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class UpdateImsYzVideoShareGoodsTable20210817 extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasTable('yz_video_share_goods')) {
Schema::table('yz_video_share_goods', function (Blueprint $table) {
if (!Schema::hasColumn('yz_video_share_goods', 'store_id')) {
$table->integer('store_id')->default(0)->comment('门店id');
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('yz_video_share_goods', function (Blueprint $table) {
$table->dropColumn('store_id');
});
}
}

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateYzVideoShareGoodsTable20220124 extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasTable('yz_video_share_goods')) {
Schema::table('yz_video_share_goods', function (Blueprint $table) {
if (!Schema::hasColumn('yz_video_share_goods', 'is_crm')) {
$table->tinyInteger('is_crm')->default(0)->comment("是否crm推送0否1是");
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('yz_video_share_goods', function (Blueprint $table) {
$table->dropColumn('is_crm');
});
}
}

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterTableYzVideoShareGoodsAddColumnYzGoodsId extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasTable('yz_video_share_goods')) {
Schema::table('yz_video_share_goods', function (Blueprint $table) {
if (!Schema::hasColumn('yz_video_share_goods', 'mid_ground_video_id')) {
$table->tinyInteger('mid_ground_video_id')->default(0)->comment("中台视频id");
}
if (!Schema::hasColumn('yz_video_share_goods', 'mid_ground_config_id')) {
$table->tinyInteger('mid_ground_config_id')->default(0)->comment("中台配置id");
}
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -0,0 +1,11 @@
{
"name": "video-share",
"terminal": "wechat|min|wap",
"version": "1.0.118",
"title": "视频分享",
"description": "短视频营销,带货传播更便捷。",
"author": "",
"url": "",
"namespace": "Yunshop\\VideoShare",
"config": "config.tpl"
}

View File

@ -0,0 +1,581 @@
<?php
namespace Yunshop\VideoShare;
use app\common\modules\shop\ShopConfig;
use Yunshop\VideoDemand\Listener\ChargeComplatedListener;
use Yunshop\VideoDemand\Listener\OrderReceiveListener;
use Yunshop\VideoShare\common\service\MemberCenterService;
use Yunshop\VideoShare\common\service\TimedTaskImportService;
use Yunshop\VideoShare\common\service\TimedTaskService;
class PluginApplication extends \app\common\services\PluginApplication
{
public function getMemberCenterConfig()
{
\app\common\modules\shop\MemberCenterConfig::current()->push('plugin_data',[
'code' => 'video-share',
'name' => '发现视频',
'sort' => 5,
'class' => '\Yunshop\VideoShare\common\member\MemberCenterVideoShare'
]);
}
public function storeAloneTempConfig()
{
\Yunshop\StoreAloneTemp\common\StoreAloneTempConfig::current()->push('navs',[
'sort' => 3,
'code' => 'video_share',
'name' => '发现视频',
'class' => '\Yunshop\VideoShare\common\member\StoreMemberCenterVideoShare',
]);
$set = \Setting::get('plugin.video-share');
if ($set['is_open']) {
\Yunshop\StoreAloneTemp\common\StoreAloneTempConfig::current()->push('plugins',[
'name' => 'video-share',
'title' => '发现视频',
'class' => 'icon-extension_video',
'url' => $set['list_style'] == 2 ? 'VideoDetail' : 'VideoList',
'image' => 'member_a(73).png',
'mini_url' => $set['list_style'] == 2 ? '/packageC/video_goods/VideoDetail/VideoDetail' : '/packageC/video_goods/VideoList/VideoList',
]);
}
}
public function getIncomePageItems()
{
return [
'video_share_income' => [
'class' => \Yunshop\VideoShare\common\service\IncomePageService::class,
'type' => 'marketing'
]
];
}
protected function setConfig()
{
\Config::set('widget.withdraw.tab_video_share', [
'title' => '发现视频',
'class' => \Yunshop\VideoShare\admin\withdrawWidget::class
]);
\app\common\modules\shop\ShopConfig::current()->set('get_video_access', [
'class' => 'Yunshop\VideoShare\common\service\ShopService',
'function' => 'getAccess'
]);
}
public function getIncomeItems()
{
return ['video_share' => [
'title' => '发现视频',
'type' => 'video_share_withdraw',
'class' => \Yunshop\VideoShare\common\model\Bonus::class,
'order_class' => '',
]];
}
public function getWidgetItems()
{
return ['withdraw.tab_video_share' => [
'title' => '视频分享',
'class' => 'Yunshop\VideoShare\widgets\WithdrawWidget'
]];
}
protected function setMenuConfig()
{
\app\backend\modules\menu\Menu::current()->setPluginMenu('video_share', [
'name' => '视频分享',
'type' => 'marketing',
'url' => 'plugin.video-share.admin.videoGoods.index',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'top_show' => 0,
'left_first_show' => 0,
'left_second_show' => 1,
'icon' => 'fa-list',
'list_icon' => 'share-chain',
'item' => 'video_share',
'parents' => [],
'child' => [
'video_goods_manage' => [
'name' => '发现管理',
'url' => 'plugin.video-share.admin.videoGoods.index',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_manage',
'parents' => ['video_share'],
'child' => [
'video_goods_search' => [
'name' => '搜索',
'url' => 'plugin.video-share.admin.video-goods.search',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_search',
'parents' => ['video_share','video_goods_manage'],
'child' => []
],
'video_goods_del' => [
'name' => '分红记录',
'url' => 'plugin.video-share.admin.video-goods.del',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_del',
'parents' => ['video_share','video_goods_manage'],
'child' => []
],
'video_goods_get_images' => [
'name' => '获取图片',
'url' => 'plugin.video-share.admin.set.get-images',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_get_images',
'parents' => ['video_share','video_goods_manage'],
'child' => []
],
'video_goods_preview' => [
'name' => '视频预览',
'url' => 'plugin.video-share.admin.video-goods.video',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_preview',
'parents' => ['video_share'],
'child' => []
],
'video_goods_change_status' => [
'name' => '审核',
'url' => 'plugin.video-share.admin.video-goods.changeStatus',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_change_status',
'parents' => ['video_share','video_goods_manage'],
'child' => []
],
'video_goods_video' => [
'name' => '预览视频',
'url' => 'plugin.video-share.admin.video-goods.video',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_video',
'parents' => ['video_share','video_goods_manage'],
'child' => []
],
'video_goods_change_recommend' => [
'name' => '推荐修改',
'url' => 'plugin.video-share.admin.video-goods.changeRecommend',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_change_recommend',
'parents' => ['video_share','video_goods_manage'],
'child' => []
],
'video_goods_change_category' => [
'name' => '分类修改',
'url' => 'plugin.video-share.admin.video-goods.changeCategory',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_change_category',
'parents' => ['video_share','video_goods_manage'],
'child' => []
],
'video_goods_change_title' => [
'name' => '标题修改',
'url' => 'plugin.video-share.admin.video-goods.edit-title',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_change_title',
'parents' => ['video_share','video_goods_manage'],
'child' => []
],
'video_goods_change_getGoodList' => [
'name' => '商品修改',
'url' => 'plugin.video-share.admin.video-goods.get-goods-list',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_change_getGoodList',
'parents' => ['video_share','video_goods_manage'],
'child' => []
],
'video_goods_change_good_video' => [
'name' => '更换视频',
'url' => 'plugin.video-share.admin.video-goods.upload-audio',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_change_good_video',
'parents' => ['video_share','video_goods_manage'],
'child' => []
],
'video_goods_change_url' => [
'name' => '更换视频地址',
'url' => 'plugin.video-share.admin.video-goods.change-url',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_change_good_video',
'parents' => ['video_share','video_goods_manage'],
'child' => []
],
]
],
'video_goods_bonus' => [
'name' => '分红记录',
'url' => 'plugin.video-share.admin.bonus.index',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_bonus',
'parents' => ['video_share'],
'child' => [
'video_goods_getListBySearch' => [
'name' => '搜索',
'url' => 'plugin.video-share.admin.bonus.getListBySearch',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_getListBySearch',
'parents' => ['video_share','video_goods_bonus'],
'child' => []
],
]
],
/*'diy_queue_log' => [
'name' => '奖励记录',
'url' => 'plugin.diy-queue.admin.diy-queue.award-log',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'diy_queue_log',
'parents' => ['diy_queue'],
'child' => [
]
],
'diy_queue_manage' => [
'name' => '队列管理',
'url' => 'plugin.diy-queue.admin.diy-queue-manage.manage',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'diy_queue_manage',
'parents' => ['diy_queue'],
'child' => [
'diy_queue_add' => [
'name' => '添加',
'url' => 'plugin.diy-queue.admin.diy-queue-manage.add',
'url_params' => '',
'permit' => 1,
'menu' => 0,
'icon' => '',
'item' => 'diy_queue_add',
'parents' => ['diy_queue', 'diy_queue_manage'],
'child' => []
],
'diy_queue_edit' => [
'name' => '修改',
'url' => 'plugin.diy-queue.admin.diy-queue-manage.edit',
'url_params' => '',
'permit' => 1,
'menu' => 0,
'icon' => '',
'item' => 'diy_queue_edit',
'parents' => ['diy_queue', 'diy_queue_manage'],
'child' => []
],
]
],*/
'video_goods_set' => [
'name' => '基础设置',
'url' => 'plugin.video-share.admin.set.index',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_set',
'parents' => ['video_share'],
'child' => [
'video_members_search' => [
'name' => '会员搜索',
'url' => 'plugin.video-share.admin.set.get-member',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_set',
'parents' => ['video_share','video_goods_set'],
'child' => []
],
'videoShareGetImages' => [
'name' => '获取图片',
'url' => 'plugin.video-share.admin.set.get-images',
'url_params' => '',
'permit' => 0,
'menu' => 0,
'icon' => '',
'item' => 'videoShareGetImages',
'parents' => ['video_share', 'video_goods_set'],
],
'video_goods_pic' => [
'name' => '获取图片',
'url' => 'upload.uploadImage.getImage',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_pic',
'parents' => ['video_share', 'video_goods_set'],
],
'video_goods_sub' => [
'name' => '保存数据',
'url' => 'plugin.video-share.admin.set.sub',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_sub',
'parents' => ['video_share', 'video_goods_set'],
'child' => []
],
]
],
'video_goods_category' => [
'name' => '分类管理',
'url' => 'plugin.video-share.admin.category.index',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_category',
'parents' => ['video_share'],
'child' => [
'video_goods_category_search' => [
'name' => '分类搜索',
'url' => 'plugin.video-share.admin.category.search',
'url_params' => '',
'permit' => 0,
'menu' => 0,
'icon' => '',
'item' => 'video_goods_category_search',
'parents' => ['video_share', 'video_goods_category'],
],
'video_goods_category_edit' => [
'name' => '分类编辑',
'url' => 'plugin.video-share.admin.category.edit',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_category_edit',
'parents' => ['video_share', 'video_goods_category'],
],
'video_goods_category_del' => [
'name' => '分类删除',
'url' => 'plugin.video-share.admin.category.del',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_category_del',
'parents' => ['video_share', 'video_goods_category'],
'child' => []
],
'video_goods_category_change' => [
'name' => '分类上下架',
'url' => 'plugin.video-share.admin.category.changeStatus',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_category_change',
'parents' => ['video_share', 'video_goods_category'],
'child' => []
],
]
],
'video_comments_category' => [
'name' => '评论管理',
'url' => 'plugin.video-share.admin.video-comments.index',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_comments_category',
'parents' => ['video_share'],
'child' => [
'video_comments_search' => [
'name' => '评论列表',
'url' => 'plugin.video-share.admin.video-comments.get-comments-category-list',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_comments_search',
'parents' => ['video_share', 'video_comments_category'],
],
'video_goods_category_del' => [
'name' => '评论删除',
'url' => 'plugin.video-share.admin.video-comments.del',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_category_del',
'parents' => ['video_share', 'video_comments_category'],
'child' => []
],
'video_goods_display_comments' => [
'name' => '查看评论',
'url' => 'plugin.video-share.admin.video-comments.display-comments',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_display_comments',
'parents' => ['video_share','video_comments_category'],
'child' => []
],
'video_goods_get_display_comments_list' => [
'name' => '评论列表',
'url' => 'plugin.video-share.admin.video-comments.get-display-comments-list',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_get_display_comments_list',
'parents' => ['video_share','video_comments_category'],
'child' => []
],
]
],
'video_goods_center' => [
'name' => '短视频中心',
'url' => 'plugin.video-share.admin.center.index',
'url_params' => '',
'permit' => 1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_center',
'parents' => ['video_share'],
'child' => [
'video_goods_center_goods_list' => [
'name' => '获取中台商品列表',
'url' => 'plugin.video-share.admin.center.goods-list',
'url_params' => '',
'permit' =>0,
'menu' => 0,
'icon' => '',
'item' => 'video_goods_center_goods_list',
'parents' => ['video_share','video_goods_center'],
'child' => []
],
'video_goods_center_member_list' => [
'name' => '获取会员列表',
'url' => 'plugin.video-share.admin.center.getMemberList',
'url_params' => '',
'permit' =>0,
'menu' => 0,
'icon' => '',
'item' => 'video_goods_center_member_list',
'parents' => ['video_share','video_goods_center'],
'child' => []
],
'video_goods_center_import' => [
'name' => '导入',
'url' => 'plugin.video-share.admin.center.select',
'url_params' => '',
'permit' =>1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_center_import',
'parents' => ['video_share','video_goods_center'],
'child' => []
],
'video_goods_center_all_import' => [
'name' => '全部导入',
'url' => 'plugin.video-share.admin.center.all-select',
'url_params' => '',
'permit' =>1,
'menu' => 1,
'icon' => '',
'item' => 'video_goods_center_all_import',
'parents' => ['video_share','video_goods_center'],
'child' => []
],
]
],
]
]);
}
public function getFrontendWidgetConfig(): array
{
return [
'member_center.video-share' => MemberCenterService::class,
];
}
public function boot()
{
$events = app('events');
// 监听下单
$events->subscribe(\Yunshop\VideoShare\common\listeners\OrderCreatedListener::class);
// 监听完成
$events->subscribe(\Yunshop\VideoShare\common\listeners\OrderReceiveListener::class);
$events->subscribe(\Yunshop\VideoShare\common\listeners\VideoPublishListener::class);
//定时同步中台短视频
}
public function cronConfig()
{
\Event::listen('cron.collectJobs', function () {
\Cron::add('video-share-middle-update', '15 2 * * *', function () {
(new TimedTaskService())->handle();
});
\Cron::add('video-share-middle-insert', '0 0 * * *', function () {
(new TimedTaskImportService())->handle();
});
});
}
}

View File

@ -0,0 +1,89 @@
<?php
namespace Yunshop\VideoShare\admin;
use app\common\components\BaseController;
use Yunshop\VideoShare\common\model\Bonus;
class BonusController extends BaseController
{
// 分红列表 可以指定视频id
public function index()
{
$search = request()->search;
$statistic = $this->getStatistic($search);
$list = Bonus::getList($search)
->orderBy('id', 'desc')
->paginate();
$list = $this->processData($list);
return view('Yunshop\VideoShare::bonus.list', [
'list' => json_encode($list),
'statistic' => json_encode($statistic)
])->render();
}
// 分红列表搜索
public function getListBySearch()
{
$search = request()->search;
$statistic = $this->getStatistic($search);
$list = Bonus::getList($search)
->orderBy('id', 'desc')
->paginate();
$list = $this->processData($list);
return $this->successJson('成功', [
'list' => $list,
'statistic' => $statistic
]);
}
private function getStatistic($search)
{
$order_price = Bonus::getList($search)->sum('order_price');
$amount = Bonus::getList($search)->sum('amount');
$finish_order_price = Bonus::getList($search)->where('status', 1)->sum('order_price');
$wait_amount = Bonus::getList($search)->where('status', 1)->sum('amount');
return [
'order_price' => $order_price,
'amount' => $amount,
'finish_order_price' => $finish_order_price,
'wait_amount' => $wait_amount,
];
}
/**
* 数据过滤
*/
private function processData($obj='')
{
/*************************修复视频被删除后无法显示记录*************************/
if (is_array($obj))
{
$list = $obj;
}else{
$list = $obj->toArray();
}
foreach ($list['data'] as $key => $value)
{
if ($value['video'] == null)
{
$list['data'][$key]['video'] = ['id'=>'视频被删除','title'=>'视频被删除'];
}
}
return $list;
/*************************修复视频被删除后无法显示记录end*************************/
}
}

View File

@ -0,0 +1,124 @@
<?php
namespace Yunshop\VideoShare\admin;
use app\common\components\BaseController;
use Yunshop\VideoShare\common\model\CategoryModel;
use Yunshop\VideoShare\common\model\VideoShareGoods;
class CategoryController extends BaseController
{
public function index()
{
$search = request()->search;
$list = CategoryModel::uniacid()->search($search)->orderBy("id","desc")->paginate(15);
$list = empty($list) ? [] : $list->toArray();
if (!empty($list['data'])) {
foreach ($list['data'] as $kk=>$vv) {
$amount_total = VideoShareGoods::uniacid()->where("category_id",$vv['id'])->count();
$list['data'][$kk]['amount_total'] = $amount_total;
}
}
return view('Yunshop\VideoShare::category.list',[
'list' => json_encode($list),
'search' => json_encode($search)
])->render();
}
public function edit()
{
$cate_id = request()->get("cate_id");
$cate_data = request()->cate_data;
$cate = [];
if (!empty($cate_data)) {
if ($cate_id) {
$category = CategoryModel::uniacid()->where("id",$cate_id)->first();
} else {
$category = new CategoryModel();
}
$data = [
"uniacid" => \YunShop::app()->uniacid,
"name" => $cate_data['name'],
"sort" => $cate_data['sort'],
"is_show" => $cate_data['is_show']
];
$category->fill($data);
if ($category->save()) {
return $this->successJson("编辑成功");
}
return $this->errorJson("编辑失败");
}
if ($cate_id) {
$cate = CategoryModel::uniacid()->where("id",$cate_id)->first();
$cate = empty($cate) ? [] : $cate->toArray();
}
return view('Yunshop\VideoShare::category.edit',[
"cate" => $cate
])->render();
}
public function search()
{
$search = request()->search;
$list = CategoryModel::uniacid()->search($search)->paginate(15);
$list = empty($list) ? [] : $list->toArray();
if (!empty($list['data'])) {
foreach ($list['data'] as $kk=>$vv) {
$amount_total = VideoShareGoods::uniacid()->where("category_id",$vv['id'])->count();
$list['data'][$kk]['amount_total'] = $amount_total;
}
}
return $this->successJson("",["list"=>$list]);
}
public function del()
{
$id = request()->get("id");
$cate = CategoryModel::uniacid()->where("id",$id)->first();
if (empty($cate)) {
return $this->errorJson("分类不存在");
}
$rel = CategoryModel::uniacid()->where("id",$id)->delete();
if ($rel) {
return $this->successJson("删除成功");
} else {
return $this->errorJson("删除失败");
}
}
public function changeStatus()
{
$id = request()->get("id");
$cate = CategoryModel::uniacid()->where("id",$id)->first();
if (empty($cate)) {
return $this->errorJson("分类不存在");
}
$cate->is_show = ($cate->is_show == 1) ? 2 : 1;
$cate->save();
return $this->successJson('成功', []);
}
}

View File

@ -0,0 +1,297 @@
<?php
namespace Yunshop\VideoShare\admin;
use app\common\components\BaseController;
use app\common\exceptions\ShopException;
use app\common\models\Category;
use app\common\models\Member;
use Illuminate\Support\Facades\Redis;
use app\common\exceptions\AppException;
use Yunshop\VideoShare\common\service\TimedTaskImportService;
use Yunshop\VideoShare\common\model\CategoryModel;
use Yunshop\VideoShare\common\model\VideoShareGoods;
use Yunshop\VideoShare\common\service\CloudRequestService;
use Yunshop\VideoShare\common\job\AllImportJob;
use Yunshop\YzSupply\models\MiddlegroundConfiguration;
use Yunshop\YzSupply\models\YzGoods;
use Yunshop\YzSupply\services\GoodsImportService;
class CenterController extends BaseController
{
public function index()
{
if(!app('plugins')->isEnabled('yz-supply')){
throw new ShopException('请先开启供应链插件!');
}
$category_list = $this->shopCategory();
$video_category_list=$this->getVideoCate();
$import = $this->_getImportRedis();
return view('Yunshop\VideoShare::center.index', [
'category_level' => \Setting::get('shop.category.cat_level') ?: 2,
'category_list' => json_encode($category_list),
'video_category_list'=>json_encode($video_category_list),
'create_category' => 1,
'import' => json_encode($import),
'topic_id' => request()->topicId ?: 0,
])->render();
}
public function _getImportRedis()
{
$uniacid = \YunShop::app()->uniacid;
$redis_key = 'yz_supply_import';
$redis_import = $uniacid . '_import';
$all_page_import = $uniacid . '_import_page';
$now_page_import = $uniacid . '_import_now_page';
$total_import = $uniacid . '_import_total';
$import_status = Redis::hget($redis_key, $redis_import);
if ($import_status == '0') {
//导入进度
$import['import_process'] = number_format(Redis::hget($redis_key, $now_page_import) / Redis::hget($redis_key, $all_page_import) * 100, 2);
$import['import_total'] = Redis::hget($redis_key, $total_import);
$import['import_exits'] = Redis::hget($redis_key, $now_page_import) * $this->importSize;
$import['import_status'] = 1;
} else {
$import['import_status'] = 0;
}
return $import;
}
/**
* 选择会员
* @return \Illuminate\Http\JsonResponse
*/
public function getMemberList()
{
$kwd = request()->keyword;
$members = [];
if ($kwd) {
$members = \app\backend\modules\member\models\Member::select(['uid', 'nickname', 'avatar', 'mobile', 'realname'])->join('yz_member', function ($join) {
$join->on('mc_members.uid', 'yz_member.member_id')->whereNull('yz_member.deleted_at');
})->uniacid()->searchLike($kwd)->paginate(10)->toArray();
}
return $this->successJson('', $members);
}
protected function shopCategory()
{
$set = \Setting::get('shop.category');
$list = Category::getCategorys(0)->select('id', 'name', 'enabled')->pluginId()->get();
$list->map(function ($category) use ($set) {
$childrens = Category::getChildrenCategorys($category->id, $set)->select('id', 'name', 'enabled')->get()->toArray();
foreach ($childrens as $key => &$children) {
if ($set['cat_level'] == 3 && $children['has_many_children']) {
$children['childrens'] = $children['has_many_children'];
} else {
$children['childrens'] = [];
}
}
$category->childrens = $childrens;
});
return $list;
}
public function select()
{
//中台商品处理
$categorySearch = array_filter(request()->category, function ($item) {
return is_array($item) ? !empty($item[0]) : !empty($item);
});
$set = \Setting::get('plugin.video-share');
if(!$categorySearch['video_id']){
throw new AppException('请选择要导入的短视频分类');
}
$videoId=$categorySearch['video_id'];
unset($categorySearch['video_id']);
if($categorySearch['member_id']<=0&&$set['default_member_id']<=0){
throw new AppException('请选择关联用户,或者到基础设置里设置默认用户!');
}
$memberId=$categorySearch['member_id'];
unset($categorySearch['member_id']);
$all_yz_goods_ids =array_column(request()->goods_ids,'product_id');
$middleground_configuration_id =request()->middleground_configuration_id;
$extra['f_value_id'] = intval(request()->f_value_id);
$set = \Setting::get('plugin.yz_supply');
if ($set['create_category'] != 1) {
if (!$categorySearch) {
throw new AppException('请选择要导入的分类');
}
if (!$categorySearch['parentid']) {
throw new AppException('请选择一级分类');
}
if (!$categorySearch['childid']) {
throw new AppException('请选择二级分类');
}
if (\Setting::get('shop.category')['cat_level'] == 3 && !$categorySearch['thirdid']) {
throw new AppException('请选择三级分类');
}
}
if (!$all_yz_goods_ids) {
throw new AppException('请选择至少一件商品');
}
$errorGoodsIds = GoodsImportService::beforeImport($all_yz_goods_ids, $categorySearch, $extra,$middleground_configuration_id);
if ($errorGoodsIds) {
$string_error = implode(',', $errorGoodsIds);
return $this->errorJson('商品导入供应链选品库失败ID:' . $string_error, []);
}
//短视频处理
$videoData=[];
$set = \Setting::get('plugin.video-share');
$memberId=$memberId>0?$memberId:$set['default_member_id'];
$shopGoodsIds=YzGoods::uniacid()->whereIn('yz_goods_id',$all_yz_goods_ids)->pluck('goods_id','yz_goods_id')->toArray();
foreach (request()->goods_ids as $val) {
$exist=VideoShareGoods::uniacid()->where(['mid_ground_video_id'=>$val['id'],'mid_ground_config_id'=>request()->middleground_configuration_id])->first();
if($exist){
$exist->update([
'goods_id' => $shopGoodsIds[$val['product_id']],
'uid' => $memberId,
'title' => $val['origin_title'],
'video' => $val['video_url'] ?: '',
'file_name' => '',
'cover' => $val['cover_url'] ?: '',
'status' => 1,
'category_id' => $videoId?:0,
'updated_at'=>time()
]);
}else{
$videoData[] = [
'goods_id' => $shopGoodsIds[$val['product_id']],
'uniacid' => \YunShop::app()->uniacid,
'uid' => $memberId,
'title' => $val['origin_title'],
'video' => $val['video_url'] ?: '',
'file_name' => '',
'cover' => $val['cover_url'] ?: '',
'share_num' => 0,
'like_num' => 0,
'order_price' => 0,
'amount_total' => 0,
'status' => 1,
'category_id' => $videoId?:0,
'created_at'=>time(),
'updated_at'=>time(),
'mid_ground_video_id'=>$val['id'],
'mid_ground_config_id'=>request()->middleground_configuration_id
];
}
}
VideoShareGoods::insert($videoData);
(new CloudRequestService(request()->middleground_configuration_id))->addVideoStorage(array_column(request()->goods_ids,'id'));
return $this->successJson('导入成功!');
}
public function goodsList()
{
$page = request()->input('page', 1);
$search = request()->input('search', []);
$page_size = intval($search['goods_page_size'] ?: 20);
$search['page'] = $page;
$search['pageSize'] = $page_size;
try {
$list = (new CloudRequestService(request()->middleground_configuration_id))->goodsList($search,true);
} catch (\Exception $e) {
return $this->errorJson($e->getMessage());
}
return $this->successJson('success', $list['data']);
}
public function allSelect()
{
$categorySearch = array_filter(request()->category, function ($item) {
return is_array($item) ? !empty($item[0]) : !empty($item);
});
$set = \Setting::get('plugin.video-share');
if(!$categorySearch['video_id']){
throw new AppException('请选择要导入的短视频分类');
}
if(!$categorySearch['member_id']&&!$set['default_member_id']){
throw new AppException('请选择关联用户,或者到基础设置里设置默认用户!');
}
$middleground_configuration_id = request()->middleground_configuration_id;
$extra['f_value_id'] = intval(request()->f_value_id);
$set = \Setting::get('plugin.yz_supply');
if ($set['create_category'] != 1) {
if (!$categorySearch) {
throw new AppException('请选择要导入的分类');
}
if (!$categorySearch['parentid']) {
throw new AppException('请选择一级分类');
}
if (!$categorySearch['childid']) {
throw new AppException('请选择二级分类');
}
if (\Setting::get('shop.category')['cat_level'] == 3 && !$categorySearch['thirdid']) {
throw new AppException('请选择三级分类');
}
} else {
if ($categorySearch && !$categorySearch['childid']) {
throw new AppException('请选择二级分类');
}
if ($categorySearch && \Setting::get('shop.category')['cat_level'] == 3 && !$categorySearch['thirdid']) {
throw new AppException('请选择三级分类');
}
}
$list = (new \Yunshop\VideoShare\common\service\CloudRequestService($middleground_configuration_id))->goodsList([]);
$count = $list['data']['total'];
if($count>2000) $count = 2000;//固定最大值2000
$all_page = (int)ceil($count / 10);
$uniacid = \YunShop::app()->uniacid;
for ($page = 1; $page <= $all_page; $page++) {
usleep(50000); //延迟尽量避免同时请求中台 造成中台不返回数据
$this->dispatch(new AllImportJob($categorySearch, $page, [], $uniacid, $extra,$middleground_configuration_id));
}
$redis_key = 'yz_supply_video_import';
$redis_import = $uniacid . '_video_import';
$all_page_import = $uniacid . '_video_import_page';
$now_page_import = $uniacid . '_video_import_now_page';
$total_import = $uniacid . '_video_import_total';
Redis::hset($redis_key, $redis_import, 0);
Redis::hset($redis_key, $all_page_import, $all_page);
Redis::hset($redis_key, $now_page_import, 0);
Redis::hset($redis_key, $total_import, $count);
return $this->successJson('短视频导入请求成功', []);
}
public function getVideoCate(){
$list=CategoryModel::uniacid()->get()->toArray();
return $list;
}
public function getMidGroundList(){
if(!app('plugins')->isEnabled('yz-supply')){
return $this->successJson('success',[]);
}
$where[] = ['status',1];
$data = MiddlegroundConfiguration::uniacid()->where($where)->orderBy('sort','desc')->orderBy('id','desc')->get();
return $this->successJson("success",$data);
}
public function manual(){
(new TimedTaskImportService())->handle();
return $this->successJson('success');
}
}

View File

@ -0,0 +1,212 @@
<?php
namespace Yunshop\VideoShare\admin;
use app\backend\modules\member\models\Member;
use app\backend\modules\uploadVerificate\UploadVerificationBaseController;
use app\common\components\BaseController;
use app\platform\modules\application\models\CoreAttach;
use Yunshop\VideoShare\common\model\CategoryModel;
use Yunshop\YzSupply\models\MiddlegroundConfiguration;
class SetController extends UploadVerificationBaseController
{
public function index()
{
/*return view('Yunshop\VideoShare::videoGoods.image', [
'path' => request()->getSchemeAndHttpHost().'/addons/yun_shop'.\Storage::disk('audios')->url('1565339320858506.mp4')
])->render();*/
$url = uploadUrl('new');
$set = \Setting::get('plugin.video-share');
if(!empty($set['releaserMember'])){
$member = Member::select('uid', 'nickname', 'avatar', 'mobile')->uniacid()->whereIn('uid', $set['releaserMember'])->get();
}
$type = 0;
if (config('app.framework') == 'platform') {
$type = 1;
}
if($set['default_member_id']){
$defaultMember = Member::select('uid', 'nickname', 'avatar', 'mobile')->uniacid()->where('uid', $set['default_member_id'])->first();
}
$set['page'] = yzAppFullUrl('VideoList');
$set['mini_page'] = '/packageC/video_goods/VideoList/VideoList';
$category = CategoryModel::uniacid()->select("id","name")->where("is_show",1)->orderBy('sort','desc')->get();
$category = empty($category) ? [] : $category->toArray();
return view('Yunshop\VideoShare::set.index', [
'url' => json_encode($url),
'set' => json_encode($set),
'type' => json_encode($type),
'choosedStore'=>json_encode($defaultMember?:[]),
'category' => json_encode($category),
'releaserMember' => json_encode($member ? $member : []),
'pluginStatus' => json_encode($this->getPluginStatus()),
])->render();
}
public function getImages()
{
$thumb = CoreAttach::uniacid()->where('type', 1);
if (request()->year != '不限') {
$search['year'] = request()->year;
}
if(request()->month != '不限') {
$search['month'] = request()->month;
}
$thumb = $thumb->orderBy('id', 'desc');
if ($search) {
$thumb = $thumb->search($search);
}
$url = $thumb->paginate()->toArray();
$url['data'] = collect($url['data'])->map(function ($thumb) {
$collection = collect($thumb)->put('url', yz_tomedia($thumb['attachment']));
return $collection;
});
$url['data'] = $url['data']->toArray();
return $this->successJson('获取成功', $url);
}
public function sub()
{
$setdata = request()->setdata;
if ($setdata) {
if (\Setting::set('plugin.video-share', $setdata)) {
return $this->successJson('保存成功');
}
} else {
return $this->errorJson('参数错误');
}
}
public function getReleaser()
{
$releaser = [
'member' => '会员',
'agent' => '推广员',
'appoint_member' => '指定会员'
];
$teamDividend = app('plugins')->isEnabled('team-dividend');
if ($teamDividend) {
$releaser['team_dividend'] = '经销商';
}
$store = app('plugins')->isEnabled('store-cashier');
if ($store) {
$releaser['store'] = '门店店长/店员';
}
$hotel = app('plugins')->isEnabled('hotel');
if ($hotel) {
$releaser['hotel'] = '酒店店长/店员';
}
$supplier = app('plugins')->isEnabled('supplier');
if ($supplier) {
$releaser['supplier'] = '供应商';
}
return $this->successJson('获取发布者成功', [
'releaser' => $releaser
]);
}
public function getUploadUrl()
{
$thumb = new CoreAttach();
if (request()->year != '不限') {
$search['year'] = request()->year;
}
if(request()->month != '不限') {
$search['month'] = request()->month;
}
$thumb = $thumb->where('uniacid', \YunShop::app()->uniacid)->orderBy('id', 'desc');
if ($search) {
$thumb = $thumb->search($search);
}
$list = $thumb->paginate()->toArray();
$list['data'] = collect($list['data'])->map(function ($thumb) {
$thumb['thumb'] = yz_tomedia($thumb['thumb'], true);
return $thumb;
});
$list['data'] = $list['data']->toArray();
return $this->successJson('获取成功', [
'list' => $list,
]);
}
public function getMember()
{
$keyword = request()->keyword;
$member = Member::select('uid', 'nickname', 'avatar', 'mobile')->uniacid()->searchLike($keyword)->get();
return $this->successJson('获取成功',$member);
}
//获取插件状态
protected function getPluginStatus()
{
$result = [
'member' => true,
'agent' => true,//推广员
'appoint_member' => true,//指定会员
'team_dividend'=>false,//经销商
'store'=>false,//门店店长/店员
'hotel'=>false,//酒店
'supplier'=>false//供应商
];
$teamDividend = app('plugins')->isEnabled('team-dividend');
if ($teamDividend) {
$result['team_dividend'] = true;
}
$store = app('plugins')->isEnabled('store-cashier');
if ($store) {
$result['store'] = true;
}
$hotel = app('plugins')->isEnabled('hotel');
if ($hotel) {
$result['hotel'] = true;
}
$supplier = app('plugins')->isEnabled('supplier');
if ($supplier) {
$result['supplier'] = true;
}
return $result;
}
public function getVideoCate(){
$list=CategoryModel::uniacid()->get()->toArray();
return $this->successJson('success',$list);
}
public function getMidGroundList(){
if(!app('plugins')->isEnabled('yz-supply')){
return $this->successJson('success',[]);
}
$where[] = ['status',1];
$data = MiddlegroundConfiguration::uniacid()->where($where)->orderBy('sort','desc')->orderBy('id','desc')->get();
return $this->successJson("success",$data);
}
}

View File

@ -0,0 +1,437 @@
<?php
namespace Yunshop\VideoShare\admin;
use app\common\components\BaseController;
use app\common\services\Utils;
use app\platform\modules\application\models\AppUser;
use app\platform\modules\application\models\CoreAttach;
use app\platform\modules\application\models\WechatAttachment;
use app\platform\modules\system\models\SystemSetting;
class UploadController extends BaseController
{
protected $global;
protected $remote;
protected $common;
protected $uniacid;
public function __construct()
{
$this->global = SystemSetting::settingLoad('global', 'system_global');
$this->remote = SystemSetting::settingLoad('remote', 'system_remote');
$this->common = $this->common();
$this->uniacid = \YunShop::app()->uniacid;
}
public function upload()
{
if (!$_FILES['file']['name']) {
return $this->errorJson('上传失败, 请选择要上传的文件!');
}
if ($_FILES['file']['error'] != 0) {
return $this->errorJson('上传失败, 请重试.');
}
$ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
$ext = strtolower($ext);
$originname = $_FILES['file']['name'];
$filename = file_random_name(base_path() . '/static/upload' . $this->common['folder'], $ext);
$file = $this->file_upload($_FILES['file'], $this->common['type'], $this->common['folder'] . $filename, true);
if (is_error($file)) {
return $this->errorJson($file['message']);
}
$pathname = $file['path'];
$fullname = base_path() . '/static/upload/' . $pathname;
return $this->saveData($this->common['type'], $fullname, $originname, $ext, $filename, $this->common['module_upload_dir'], $pathname, $this->common['option']);
}
public function file_upload($file, $type = 'image', $name = '', $compress = false)
{
$harmtype = array('asp', 'php', 'jsp', 'js', 'css', 'php3', 'php4', 'php5', 'ashx', 'aspx', 'exe', 'cgi');
if (!$file) {
return error(-1, '没有上传内容');
}
if (!in_array($type, array('image', 'thumb', 'voice', 'video', 'audio'))) {
return error(-2, '未知的上传类型');
}
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
$ext = strtolower($ext);
switch ($type) {
case 'image':
//$allowExt = $this->global['image_extentions'];
$allowExt = ['bmp','jpg','png','tif','gif','pcx','tga','exif','fpx','svg','psd','cdr','pcd','dxf'];
$limit = $this->global['image_limit'];
break;
case 'thumb':
case 'voice':
case 'audio':
$allowExt = $this->global['audio_extentions'];
$limit = $this->global['audio_limit'];
break;
case 'video':
$allowExt = $this->global['audio_extentions'];
$limit = $this->global['audio_limit'];
break;
}
$setting = $this->global[$type.'_extentions'];
if ($setting) {
$allowExt = array_merge($setting, $allowExt);
}
if (!in_array(strtolower($ext), $allowExt) || in_array(strtolower($ext), $harmtype)) {
return error(-3, '不允许上传此类文件');
}
/*if ($limit && $limit * 1024 < filesize($file['tmp_name'])) {
return error(-4, "上传的文件超过大小限制,请上传小于 {$limit}k 的文件");
}*/
$result = array();
if (!$name || $name == 'auto') {
$path = "/{$type}s/{$this->uniacid}" . '/'.date('Y/m/');
Utils::mkdirs(base_path() . '/static/upload' . $path);
$filename = file_random_name(base_path() . '/' . $path, $ext);
$result['path'] = $path . $filename;
} else {
Utils::mkdirs(dirname(base_path() . '/static/upload/' . $name));
if (!strexists($name, $ext)) {
$name .= '.' . $ext;
}
$result['path'] = $name;
}
$save_path = base_path() . '/static/upload/' . $result['path'];
if (!file_move($file['tmp_name'], $save_path)) {
return error(-1, '保存上传文件失败');
}
if ($type == 'image' && $compress) {
file_image_quality($save_path, $save_path, $ext, $this->global);
}
$result['success'] = true;
return $result;
}
public function saveData($type, $fullname, $originname, $ext, $filename, $module_upload_dir, $pathname, $option)
{
if ($type == 'image') {
$thumb = !$this->global['thumb'] ? 0 : 1;
$width = intval($this->global['thumb_width']);
if (isset($option['thumb'])) {
$thumb = !$option['thumb'] ? 0 : 1;
}
if (isset($option['width']) && $option['width']) {
$width = intval($option['width']);
}
if ($thumb == 1 && $width > 0) {
$thumbnail = file_image_thumb($fullname, '', $width, $this->global);
if ($thumbnail == 1) {
return $this->errorJson('创建目录失败');
} elseif ($thumbnail == 2) {
return $this->errorJson('目录无法写入');
}
@unlink($fullname);
if (is_error($thumbnail)) {
return $this->successJson($thumbnail['message']);
} else {
$filename = pathinfo($thumbnail, PATHINFO_BASENAME);
$pathname = $thumbnail;
$fullname = base_path() . '/static/upload' . $pathname;
}
}
}
$info = array(
'name' => $originname,
'ext' => $ext,
'filename' => $pathname,
'attachment' => $pathname,
'url' => yz_tomedia($pathname),
'is_image' => $type == 'image' ? 1 : 0,
'filesize' => filesize($fullname),
'group_id' => intval(request()->group_id)
);
if ($type == 'image') {
$size = getimagesize($fullname);
$info['width'] = $size[0];
$info['height'] = $size[1];
} else {
$size = filesize($fullname);
$info['size'] = sizecount($size);
}
if ($this->remote['type']) {
$remotestatus = file_remote_upload($pathname, true, $this->remote);
if (is_error($remotestatus)) {
file_delete($pathname);
return $this->errorJson('远程附件上传失败,请检查配置并重新上传'.$remotestatus['message']);
} else {
file_delete($pathname);
$info['url'] = yz_tomedia($pathname, false, $this->remote['type']);
}
}
$core_attach = CoreAttach::create([
'uniacid' => $this->uniacid,
//'uid' => \Auth::guard('admin')->user()->uid,
'uid' => 0,
'filename' => safe_gpc_html(htmlspecialchars_decode($originname, ENT_QUOTES)),
'attachment' => $pathname ? : '',
'type' => $type == 'image' ? 1 : ($type == 'audio'||$type == 'voice' ? 2 : 3),
'module_upload_dir' => $module_upload_dir,
'group_id' => intval(request()->group_id),
'upload_type' => $this->remote['type']
]);
\Log::info('----------上传附件----------', json_encode($info));
if ($core_attach) {
$info['state'] = 'SUCCESS';
$info['state'] = 'SUCCESS';
return $this->successJson('成功', $info);
} else {
return $this->errorJson('失败');
}
}
public function image()
{
$year = request()->year;
$month = intval(request()->month);
$page = max(1, intval(request()->page));
$groupid = intval(request()->groupid);
$page_size = 24;
$is_local_image = $this->common['islocal'] == 'local' ? true : false;
if ($page<=1) {
$page = 0;
$offset = ($page)*$page_size;
} else {
$offset = ($page-1)*$page_size;
}
if(!$is_local_image) {
$core_attach = new WechatAttachment();
} else {
$core_attach = new CoreAttach;
}
$core_attach = $core_attach->where('uniacid', $this->uniacid)->where('module_upload_dir', $this->common['module_upload_dir']);
if (!$this->uniacid) {
$core_attach = $core_attach->where('uid', \Auth::guard('admin')->user()->uid);
}
if ($groupid > 0) {
$core_attach = $core_attach->where('group_id', $groupid);
}
if ($groupid == 0) {
$core_attach = $core_attach->where('group_id', -1);
}
if ($year || $month) {
$start_time = $month ? strtotime("{$year}-{$month}-01") : strtotime("{$year}-1-01");
$end_time = $month ? strtotime('+1 month', $start_time) : strtotime('+12 month', $start_time);
$core_attach = $core_attach->where('created_at', '>=', $start_time)->where('created_at', '<=', $end_time);
}
if ($this->common['islocal']) {
$core_attach = $core_attach->where('type', 1);
} else {
$core_attach = $core_attach->where('type', 'image');
}
$core_attach = $core_attach->orderby('created_at', 'desc');
$count = $core_attach->count();
$core_attach = $core_attach->offset($offset)->limit($page_size)->get();
foreach ($core_attach as &$meterial) {
if ($this->common['islocal']) {
$meterial['url'] = yz_tomedia($meterial['attachment']);
unset($meterial['uid']);
} else {
$meterial['attach'] = yz_tomedia($meterial['attachment'], true);
$meterial['url'] = $meterial['attach'];
}
}
$pager = pagination($count, $page, $page_size,'',$context = array('before' => 5, 'after' => 4, 'isajax' => '1'));
$result = array('items' => $core_attach, 'pager' => $pager);
$array = [
'message' => [
'erron' => 0,
'message' => $result
],
'redirect' => '',
'type' => 'ajax'
];
return \GuzzleHttp\json_encode($array);
}
public function fetch()
{
$url = trim(request()->url);
$size = intval($_FILES['file']['size']);
$resp = ihttp_get($url);
if (!$resp) {
return $this->errorJson('提取文件失败');
}
if ($this->common['type'] == 'image') {
switch ($resp['headers']['Content-Type']) {
case 'application/x-jpg':
case 'image/jpeg':
$ext = 'jpg';
break;
case 'image/png':
$ext = 'png';
break;
case 'image/gif':
$ext = 'gif';
break;
default:
return $this->errorJson('提取资源失败, 资源文件类型错误.');
break;
}
} else {
return $this->errorJson('提取资源失败, 仅支持图片提取.');
}
if (intval($resp['headers']['Content-Length']) > $this->global[$this->common['type'].'_limit'] * 1024) {
return $this->errorJson('上传的媒体文件过大(' . sizecount($size) . ' > ' . sizecount($this->global[$this->common['type'].'_limit'] * 1024));
}
$originname = pathinfo($url, PATHINFO_BASENAME);
$filename = file_random_name(base_path() . '/static/upload/' . $this->common['folder'], $ext);
$pathname = $this->common['folder'] . $filename;
$fullname = base_path() . '/static/upload/' . $pathname;
if (file_put_contents($fullname, $resp['content']) == false) {
return $this->errorJson('提取失败');
}
return $this->saveData($this->common['type'], $fullname, $originname, $ext, $filename, $this->common['module_upload_dir'], $pathname, $this->common['option']);
}
public function common()
{
$dest_dir = request()->dest_dir;
$type = in_array(request()->upload_type, array('image','audio','video')) ? request()->upload_type : 'image';
$option = array_elements(array('uploadtype', 'global', 'dest_dir'), $_POST);
$option['width'] = intval($option['width']);
$option['global'] = request()->global;
$islocal = request()->local == 'local';
if (preg_match('/^[a-zA-Z0-9_\/]{0,50}$/', $dest_dir, $out)) {
$dest_dir = trim($dest_dir, '/');
$pieces = explode('/', $dest_dir);
if(count($pieces) > 3){
$dest_dir = '';
}
} else {
$dest_dir = '';
}
$module_upload_dir = '';
if($dest_dir != '') {
$module_upload_dir = sha1($dest_dir);
}
if ($option['global']) {
$folder = "{$type}s/global/";
if ($dest_dir) {
$folder .= '' . $dest_dir . '/';
}
} else {
$folder = "{$type}s/{$this->uniacid}";
if (!$dest_dir) {
$folder .= '/' . date('Y/m/');
} else {
$folder .= '/' . $dest_dir . '/';
}
}
return [
'dest_dir' => $dest_dir,
'module_upload_dir' => $module_upload_dir,
'type' => $type,
'options' => $option,
'folder' => $folder,
'islocal' => $islocal
];
}
public function delete()
{
$uid = \Auth::guard('admin')->user()->uid;
$is_founder = $uid == '1' ? 1 : 0;
$role = AppUser::where('uid', $uid)->first()['role'];
if (!$is_founder && $role != 'manager' && $role != 'owner') {
return $this->errorJson('您没有权限删除文件');
}
$id = request()->id;
if (!is_array($id)) {
$id = array(intval($id));
}
$id = safe_gpc_array($id);
$core_attach = CoreAttach::where('id', $id);
if (!$this->uniacid) {
$core_attach = $core_attach->where('uid', $uid);
} else {
$core_attach = $core_attach->where('uniacid', $this->uniacid);
}
$core_attach = $core_attach->first();
if ($core_attach['upload_type']) {
$status = file_remote_delete($core_attach['attachment'], $core_attach['upload_type'], $this->remote);
} else {
$status = file_delete($core_attach['attachment']);
}
if (is_error($status)) {
return $this->errorJson($status['message']);
}
$core_attach->delete();
if ($core_attach->trashed()) {
return $this->successJson('删除成功');
} else {
return $this->errorJson('删除数据表数据失败');
}
}
public function video()
{
$server = $this->common['islocal'] ? 'local' : 'perm';
$page_index = max(1, request()->page);
$page_size = 5;
if ($page_index<=1) {
$page_index = 0;
$offset = ($page_index)*$page_size;
} else {
$offset = ($page_index-1)*$page_size;
}
$material_news_list = material_list('video', $server, array('page_index' => $page_index, 'page_size' => $page_size), $this->uniacid, $offset);
$material_list = $material_news_list['material_list'];
$pager = $material_news_list['page'];
foreach ($material_list as &$item) {
$item['createtime'] = $item['created_at']->timestamp;
$item['url'] = yz_tomedia($item['attachment']);
unset($item['uid']);
}
$result = array('items' => $material_list, 'pager' => $pager);
$array = [
'message' => [
'erron' => 0,
'message' => $result
],
'redirect' => '',
'type' => 'ajax'
];
return \GuzzleHttp\json_encode($array);
}
}

View File

@ -0,0 +1,159 @@
<?php
namespace Yunshop\VideoShare\admin;
use app\common\components\BaseController;
use app\common\exceptions\AppException;
use Illuminate\Support\Facades\DB;
use Yunshop\VideoShare\common\model\Comment;
use Yunshop\VideoShare\common\model\VideoShareGoods;
class VideoCommentsController extends BaseController
{
public function index()
{
return view('Yunshop\VideoShare::comments.comments-category')->render();
}
public function getCommentsCategoryList()
{
$search = request()->input('search');
$commentsList = Comment::uniacid();
if (isset($search['video_title'])) {
$commentsList = $commentsList->whereHas('video', function ($query) use ($search) {
$query->where('title', 'like', '%' . $search['video_title'] . '%');
});
}
if (isset($search['member_id'])) {
$commentsList = $commentsList->where('uid', 'like', '%' . $search['member_id'] . '%');
}
if (isset($search['member_msg'])) {
$commentsList = $commentsList->whereHas('member', function ($query) use ($search) {
$query->where('mobile', 'like', '%' . $search['member_msg'] . '%')
->orwhere('nickname', 'like', '%' . $search['member_msg'] . '%')
->orwhere('realname', 'like', '%' . $search['member_msg'] . '%');
});
}
if (isset($search['time'])) {
$commentsList = $commentsList->whereBetween('created_at', [$search['time']['start'], $search['time']['end']]);
}
$commentsList = $commentsList->orderBy('created_at', 'desc')->paginate();
$commentsList->getCollection()->transform(function ($model) {
return [
'id' => $model->id,
'uid' => $model->uid,
'nick_name' => $model->nick_name,
'head_img_url' => $model->head_img_url,
'content' => $model->content,
'video' => [
'video_title' => $model->video->title,
'video_url' => yz_tomedia($model->video->video),
"cover" => yz_tomedia($model->video->cover)
],
'created_at' => $model->created_at->format('Y-m-d H:i:s'),
];
});
return $this->successJson('ok', $commentsList);
}
public function displayComments()
{
$id = \YunShop::request()->id;
$finder = VideoShareGoods::uniacid()->find($id);
if (!$finder) {
throw new AppException('不存在的视频');
}
return view('Yunshop\VideoShare::comments.view-comments')->render();
}
public function getDisplayCommentsList()
{
$id = \YunShop::request()->id;
$num = Comment::uniacid()
->where('video_id', $id)
->count();
$finder = VideoShareGoods::uniacid()->find($id);
if (!$finder) {
throw new AppException('不存在的视频');
}
$commentsList = Comment::uniacid()
->with(['hasManyReply', 'hasManySupport' => function ($q) {
$q->where(['member_id' => \YunShop::app()->getMemberId(), 'status' => 1]);
}])
->where(['video_id' => $id, 'comment_id' => 0])
->orderBy('created_at', 'desc')
->orderBy('id', 'desc')
->paginate();
$commentsList->getCollection()->transform(function ($model) {
return [
'id' => $model->id,
'uid' => $model->uid,
'nick_name' => $model->nick_name,
'head_img_url' => $model->head_img_url,
'content' => $model->content,
'created_at' => $model->created_at->format('Y-m-d H:i:s'),
'children_comment' => $model->hasManyReply->transform(function ($model) {
return [
'id' => $model->id,
'nick_name' => $model->nick_name,
'head_img_url' => $model->head_img_url,
'content' => $model->content,
'created_at' => $model->created_at->format('Y-m-d H:i:s'),
'reply_name' => $model->reply_name,
];
})
];
});
return $this->successJson('ok', [
'commentsList' => $commentsList,
'num' => $num
]);
}
public function del()
{
$id = \YunShop::request()->id;
$comment = Comment::uniacid()
->where('id', $id)
->first();
if (!$comment) {
return $this->errorJson('评论不存在');
}
if ($comment->comment_id != 0) {
$comment->delete();
return $this->successJson('评论删除成功');
}
if ($comment->comment_id == 0) {
DB::beginTransaction();
try {
Comment::where('comment_id', $id)->delete();
$comment->delete();
DB::commit();
return $this->successJson('评论删除成功');
} catch (\Exception $e) {
DB::rollBack();
return $this->errorJson('评论删除失败');
}
};
}
}

View File

@ -0,0 +1,320 @@
<?php
namespace Yunshop\VideoShare\admin;
use app\common\components\BaseController;
use app\common\exceptions\ShopException;
use Yunshop\VideoShare\common\model\Goods;
use Illuminate\Support\Facades\Storage;
use Yunshop\VideoShare\common\model\CategoryModel;
use Yunshop\VideoShare\common\model\VideoShareGoods;
use Yunshop\VideoShare\common\service\CloudRequestService;
use Yunshop\VideoShare\common\service\GoodsImportService;
use Yunshop\VideoShare\common\service\YzGoodsService;
use Yunshop\YzSupply\models\YzGoods;
class VideoGoodsController extends BaseController
{
// plugin.video-share.admin.video-goods.index
public function index()
{
$search = request()->search;
$id = request()->id;
$search['id'] = $id ? : $search['id'];
$list = VideoShareGoods::getList($search)
->orderBy('id', 'desc')
->paginate();
$list->map(function ($item) {
// 图片
$item->goods->thumb = yz_tomedia($item->goods->thumb);
$item->cover = yz_tomedia($item->cover);
$item->status = intval($item->status);
});
$category = CategoryModel::uniacid()->get();
$category = empty($category) ? [] : $category->toArray();
array_unshift($category,["id"=>0,"name"=>"请选择"]);
return view('Yunshop\VideoShare::videoGoods.list', [
'list' => json_encode($list),
'search' => json_encode($search),
'category' => json_encode($category)
])->render();
}
public function test()
{
$list = VideoShareGoods::getList([])
->orderBy('id', 'desc')
->paginate();
$list->map(function ($item) {
// 图片
$item->goods->thumb = yz_tomedia($item->goods->thumb);
$item->cover = yz_tomedia($item->cover);
$item->status = intval($item->status);
});
var_dump($list->first()->status);exit();
$model = VideoShareGoods::find(20);
echo '<pre>';print_r($model->toArray());exit();
}
//中台短视频更新
public function updateYzGoods()
{
$id = intval(request()->input('id'));
$goodsId=intval(request()->input('goods_id'));
if (empty($id)||empty($goodsId)) {
throw new ShopException('参数错误');
}
if (!app('plugins')->isEnabled('yz-supply')) {
throw new ShopException('更新失败!请先启用供应链插件!');
}
$video_model=VideoShareGoods::uniacid()->find($id);
YzGoodsService::setSet($video_model->mid_ground_config_id);
$yzVideoDetail=(new \Yunshop\VideoShare\common\service\CloudRequestService($video_model->mid_ground_config_id))->goodsList(['id'=>$video_model->mid_ground_video_id,'page'=>1])['data']['list'][0]?:[];
if(empty($yzVideoDetail)){
throw new ShopException('更新失败!获取供应链短视频信息失败!');
}
$goods_model = \Yunshop\YzSupply\models\Goods::select('id', 'uniacid', 'status')->with('hasOneYzGoods')->find($goodsId);
if (!$goods_model && !$goods_model->hasOneYzGoods) {
throw new ShopException('关联商品不存在或已被删除');
}
$updateGoods=0;
if($goods_model->hasOneYzGoods->yz_goods_id==$yzVideoDetail['product_id']){
$updateGoods=$goods_model->id;
}else{
$exist=\Yunshop\YzSupply\models\YzGoods::uniacid()->where(['middleground_configuration_id'=>$video_model->mid_ground_config_id,'yz_goods_id'=>$yzVideoDetail['product_id']])->first();
if($exist){
$updateGoods=$exist->goods_id;
}
}
//商城中已存在的商品调用供应链更新商品方法,不存在的导入
if($updateGoods){
\Yunshop\YzSupply\services\YzGoodsService::updateGoods($updateGoods, \Yunshop\VideoShare\common\service\YzGoodsService::requestYz($yzVideoDetail['product_id'])['yz_goods']);
}else{
$errorGoodsIds=GoodsImportService::beforeImport([$yzVideoDetail['product_id']], [], [],$video_model->mid_ground_config_id);
if (empty($errorGoodsIds)) {
$shopGoods=YzGoods::uniacid()->where(['yz_goods_id'=>$yzVideoDetail['product_id'],'middleground_configuration_id'=>$video_model->mid_ground_config_id])->first();
if($shopGoods){
$updateGoods=$shopGoods->goods_id;
}
}
}
$video_model->update([
'title'=>$yzVideoDetail['title'],
'cover'=>$yzVideoDetail['cover_url'],
'video'=>$yzVideoDetail['video_url'],
'status'=>$yzVideoDetail['is_display'],
'goods_id'=>$updateGoods
]);
return $this->errorJson('短视频更新成功!');
}
// plugin.video-share.admin.video-goods.search
public function search()
{
$search = request()->search;
$list = VideoShareGoods::getList($search)
->orderBy('id', 'desc')
->paginate();
$list->map(function ($item) {
// 图片
$item->goods->thumb = yz_tomedia($item->goods->thumb);
$item->cover = yz_tomedia($item->cover);
});
return $this->successJson('成功', [
'list' => $list
]);
}
// plugin.video-share.admin.video-goods.changeStatus
public function changeStatus()
{
$vid = intval(request()->vid);
if (!$vid) {
return $this->errorJson('参数错误');
}
$videoGoods = VideoShareGoods::find($vid);
if (!$videoGoods) {
return $this->errorJson('未找到数据');
}
$status = $videoGoods->status == 1? 0 : 1;
$videoGoods->status = $status;
$videoGoods->save();
return $this->successJson('成功', []);
}
public function changeRecommend()
{
$vid = intval(request()->vid);
if (!$vid) {
return $this->errorJson('参数错误');
}
$videoGoods = VideoShareGoods::find($vid);
if (!$videoGoods) {
return $this->errorJson('未找到数据');
}
$status = $videoGoods->is_recommend == 1? 0 : 1;
$videoGoods->is_recommend = $status;
$videoGoods->save();
return $this->successJson('成功', []);
}
public function changeCategory()
{
$id = intval(request()->id);
if (!$id) {
return $this->errorJson('参数错误');
}
$videoGoods = VideoShareGoods::find($id);
if (!$videoGoods) {
return $this->errorJson('未找到数据');
}
$category_id = request()->get("category_id");
if (!$category_id) {
return $this->errorJson('参数错误');
}
$videoGoods->category_id = $category_id;
$videoGoods->save();
return $this->successJson('成功', []);
}
public function del()
{
$id = request()->id;
//进行文件删除
$videoGoods = VideoShareGoods::find($id);
if (empty($videoGoods)) {
return $this->errorJson('视频不存在或已删除');
}
if($videoGoods->mid_ground_video_id>0){
(new CloudRequestService($videoGoods->mid_ground_config_id))->delVideoStorage([$videoGoods->mid_ground_video_id]);
}else{
Storage::disk('audios')->delete($videoGoods->file_name);
}
$result = VideoShareGoods::where('id',$id)->delete();
if ($result) {
return $this->successJson('删除成功');
} else {
return $this->errorJson('数据异常,删除失败');
}
}
public function video()
{
$id = request()->id;
$video = VideoShareGoods::uniacid()->find($id);
if (!$video){
return $this->errorJson('找不到该视频');
}
return $this->successJson('查询成功',$video);
}
//修改视频标题
public function editTitle()
{
$data = request()->all();
if (!$data['title']){
return $this->errorJson('标题不能为空');
}
$videoShareGoods = VideoShareGoods::uniacid()->find($data['id']);
if (!$videoShareGoods) {
return $this->errorJson('视频不存在');
}
$videoShareGoods->title = $data['title'];
if (!$videoShareGoods->save()) {
return $this->errorJson('标题修改失败');
}
return $this->successJson('标题修改成功');
}
//获取商品列表
public function getGoodList()
{
$good_list = Goods::uniacid()->select('id','title','thumb')->whereNotIn('plugin_id', [46]);
if (request()->search) {
$good_list = $good_list->where(function ($q) {
$q->where('id', 'like', '%' . request()->search . '%')
->orWhere('title', 'like', '%' . request()->search . '%');
});
}
$good_list = $good_list->paginate()->toArray();
foreach ($good_list['data'] as &$item){
$item['thumb'] = yz_tomedia($item['thumb']);
}
return $this->successJson('ok',$good_list);
}
//更换关联商品
public function editGoods()
{
$res = request()->all();
if (!isset($res['goods_id']) or !isset($res['video_goods_id'])){
return $this->errorJson('参数错误');
}
$videoShareGoods = VideoShareGoods::uniacid()->find($res['video_goods_id']);
$videoShareGoods->goods_id = $res['goods_id'];
if ($videoShareGoods->save()){
return $this->successJson('修改关联商品成功');
}
return $this->errorJson('修改关联商品失败');
}
//上传视频
public function uploadAudio()
{
$id = request()->id;
$video_file = request()->input('video_file');
$cover_file = request()->input('cover_file');
$video_url = request()->input('video_url');
$type = request()->input('type');
$videoShareGoods = VideoShareGoods::uniacid()->where('id', $id)->first();
$update = [];
if ($type == 1) {
if ($video_file) {
$update['video'] = $video_file;
}
if ($cover_file) {
$update['cover'] = $cover_file;
}
} elseif ($type == 2) {
$re = "/^https(.*)[.]mp4$/";
if (!preg_match($re, request()->video_url)) {
return $this->errorJson('请输入正确的视频地址');
}
$update['video'] = $video_url;
if ($cover_file) {
$update['cover'] = $cover_file;
}
}
if (empty($update)) {
return $this->errorJson('参数不能为空');
}
if ($videoShareGoods->update($update)) {
return $this->successJson('更换视频成功');
} else {
return $this->errorJson('更换视频失败.');
}
}
}

View File

@ -0,0 +1,19 @@
<?php
namespace Yunshop\VideoShare\admin;
use app\common\components\Widget;
use app\common\facades\Setting;
class withdrawWidget extends Widget
{
public function run()
{
$set = Setting::get('withdraw.videoShare', ['roll_out_limit' => '', 'poundage_rate' => '']);
return view('Yunshop\VideoShare::widget.set', [
'set' => $set,
])->render();
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace Yunshop\VideoShare\common\events;
use app\common\events\Event;
class VideoPublishEvent extends Event
{
private $video;
public function __construct($video)
{
$this->video = $video;
}
public function getVideo()
{
return $this->video;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace Yunshop\VideoShare\common\events;
use app\common\events\Event;
class VideoWatchEvent extends Event
{
protected $video_id;
protected $member_id;
public function __construct($video_id, $member_id)
{
$this->video_id = $video_id;
$this->member_id = $member_id;
}
public function getMemberId()
{
return $this->member_id;
}
public function getVideoId()
{
return $this->video_id;
}
}

View File

@ -0,0 +1,146 @@
<?php
namespace Yunshop\VideoShare\common\job;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Redis;
use Yunshop\VideoShare\common\model\VideoShareGoods;
use Yunshop\YzSupply\models\YzGoods;
use Yunshop\YzSupply\services\GoodsImportService;
use Yunshop\YzSupply\services\YzGoodsService;
use Yunshop\VideoShare\common\service\CloudRequestService;
class AllImportJob implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
public $page;
public $uniacid;
public $search;
public $category;
public $extra;
public $middleground_configuration_id;
public $topic;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($category,$page,$search,$uniacid,$extra,$middleground_configuration_id=null,$topic=[])
{
$this->queue = 'yzsupply';
$this->page = $page;
$this->search = $search;
$this->uniacid = $uniacid;
$this->category = $category;
$this->extra = $extra;
$this->middleground_configuration_id = $middleground_configuration_id;
$this->topic = $topic;
}
/**
* Execute the job.
*
* @return bool
*/
public function handle()
{
\YunShop::app()->uniacid = $this->uniacid;
\Setting::$uniqueAccountId = $this->uniacid;
$videoId=$this->category['video_id'];
$memberId=$this->category['member_id'];
unset($this->category['video_id']);
unset($this->category['member_id']);
$redis_key = 'yz_supply_video_import';
$redis_import = $this->uniacid.'_video_import';
$all_page_import = $this->uniacid.'_video_import_page';
$now_page_import = $this->uniacid.'_video_import_now_page';
Redis::hset($redis_key,$now_page_import ,$this->page);
if ($this->page == Redis::hget($redis_key,$all_page_import)) {
Redis::hset($redis_key,$redis_import ,1);
}
$this->search['page'] = $this->page;
$this->search['pageSize'] = 10;
\Log::debug('供应链云仓一键导入middleground_configuration_id'.$this->middleground_configuration_id,$this->page);
$response = (new CloudRequestService($this->middleground_configuration_id))->goodsList(['page'=>$this->page]);
if (empty($response) || $response['code'] > 0 || empty($response['data']['list'])) {
//如果没有供应链id 终止检验
$response['msg'] = !empty($response['msg']) ? $response['msg'] : 'API返回信息异常';
\Log::debug('供应链一键导入报错--API返回信息异常'.$this->middleground_configuration_id,json_encode($response));
return true;
}
$list = $response['data']['list'];
$all_yz_goods_ids = array_unique(array_column($list,'product_id'));
$import_service = new GoodsImportService();
$result = array_chunk($all_yz_goods_ids, 30);
YzGoodsService::setSet($this->middleground_configuration_id);//设置使用那个供应链
$exits_goods = YzGoods::whereIn('yz_goods_id', $all_yz_goods_ids)->where("middleground_configuration_id",YzGoodsService::$config['id'])->pluck('yz_goods_id', 'goods_id')->toArray();
foreach ($result as $yz_goods_id) {
$res = YzGoodsService::addStorage($yz_goods_id,YzGoodsService::$config['id']);
//加入选品库失败 直接跳过
if ($res['code'] == 2){
\Log::debug('供应链一键导入:加入选品库失败'.$this->middleground_configuration_id,json_encode($res));
continue;
}
$goodsList = YzGoodsService::batchGetAllGoods($yz_goods_id,YzGoodsService::$config['id']);
foreach ($goodsList as $goods) {
$goods['topic'] = $this->topic;
try {
$result = $import_service->import($this->category, $goods, $exits_goods, $this->extra); //todo 查询导入 同步 京东商品数据 到 商城商品表
} catch (\Exception $e) {
\Log::debug('供应链一键导入报错'.$this->middleground_configuration_id,json_encode($goods));
}
}
}
$set = \Setting::get('plugin.video-share');
$memberId=$memberId>0?$memberId:$set['default_member_id'];
$shopGoodsIds=YzGoods::uniacid()->whereIn('yz_goods_id',$all_yz_goods_ids)->pluck('goods_id','yz_goods_id')->toArray();
$videoData=[];
foreach($list as $video){
$exist=VideoShareGoods::uniacid()->where(['mid_ground_config_id'=>$this->middleground_configuration_id,'mid_ground_video_id'=>$video['id']])->first();
if($exist){
$exist->update([
'goods_id' => $shopGoodsIds[$video['product_id']],
'uid' => $memberId,
'title' => $video['title'],
'video' => $video['video_url'] ?: '',
'file_name' => '',
'cover' => $video['cover_url'] ?: '',
'status' => 1,
'category_id' => $videoId?:0,
'updated_at'=>time()
]);
}else{
$videoData[] = [
'goods_id' => $shopGoodsIds[$video['product_id']],
'uniacid' => \YunShop::app()->uniacid,
'uid' => $memberId,
'title' => $video['title'],
'video' => $video['video_url'] ?: '',
'file_name' => '',
'cover' => $video['cover_url'] ?: '',
'share_num' => 0,
'like_num' => 0,
'order_price' => 0,
'amount_total' => 0,
'status' => 1,
'category_id' => $videoId?:0,
'created_at'=>time(),
'updated_at'=>time(),
'mid_ground_video_id'=>$video['id'],
'mid_ground_config_id'=>$this->middleground_configuration_id
];
}
}
(new CloudRequestService($this->middleground_configuration_id))->addVideoStorage(array_column($list,'id'));
if(!empty($videoData)){
VideoShareGoods::insert($videoData);
}
}
}

View File

@ -0,0 +1,94 @@
<?php
namespace Yunshop\VideoShare\common\listeners;
use app\common\events\order\AfterOrderCreatedImmediatelyEvent;
use app\common\models\Order;
use Illuminate\Contracts\Events\Dispatcher;
use Yunshop\VideoShare\common\model\Bonus;
use Yunshop\VideoShare\common\model\VideoShareGoods;
class OrderCreatedListener
{
public function subscribe(Dispatcher $events)
{
$events->listen(AfterOrderCreatedImmediatelyEvent::class, self::class . '@onCreate');
}
public function onCreate(AfterOrderCreatedImmediatelyEvent $event)
{
$vid = \YunShop::request()->vid;
// 没有发现id
if (!$vid) {
\Log::debug('视频分享没有vid,订单号:',$event->getOrderModel()->id);
return;
}
$set = \Setting::get('plugin.video-share');
// 没开启
if (!$set['is_open']) {
\Log::debug('视频分享插件没有开启,vid:'.$vid.'订单号:',$event->getOrderModel()->id);
return;
}
// 没有奖励比例
if (!$set['percent']) {
\Log::debug('视频分享插件没有设置奖励比例,vid:'.$vid.'订单号:',$event->getOrderModel()->id);
return;
}
$order = Order::find($event->getOrderModel()->id);
$this->handle($order, $set, $vid);
}
// 传参数为了方便测试
public function handle($order, $set, $vid)
{
\Log::debug('视频分享插件订单创建开始,vid:'.$vid.'订单号:',$order->id);
$vmodel = VideoShareGoods::select()
->where('id', $vid)
->first();
if (!$vmodel) {
\Log::debug('视频分享插件订单查询视频失败,vid:'.$vid.'订单号:',$order->id);
return;
}
if ($set['find_reward'] == 1) {
$surplus = bcsub($order->price, $order->cost_amount, 2);
$surplus = bccomp($surplus, 0, 2) == 1 ? $surplus : 0;
$amount = bcmul($surplus, bcdiv($set['percent'], 100, 4), 2);
// $surplus = $order->price-$order->cost_amount;
// $surplus = ($surplus<=0) ? 0 : $surplus;
// $amount = $surplus * $set['percent'] / 100;
} else {
$amount = bcmul($order->price, bcdiv($set['percent'], 100, 4), 2);
// $amount = $order->price * $set['percent'] / 100;
}
if ($amount <= 0) {
\Log::debug('视频分享插件订单计算金额<=0,vid:'.$vid.'订单号:',$order->id);
return;
}
Bonus::create([
'uniacid' => $order->uniacid,
'uid' => $vmodel->uid,
'vid' => $vid,
'order_id' => $order->id,
'ratio' => $set['percent'],
'order_price' => $order->price,
'amount' => $amount,
'status' => 0,
'create_month' => date('Y-m')
]);
$vmodel->order_price = bcadd($vmodel->order_price,$order->price,2);
$vmodel->amount_total = bcadd($vmodel->amount_total,$amount,2);
// $vmodel->order_price += $order->price;
// $vmodel->amount_total += $amount;
$vmodel->save();
\Log::debug('视频分享插件订单创建结束,vid:'.$vid.'订单号:'.$order->id,[$order->price,$amount]);
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace Yunshop\VideoShare\common\listeners;
use app\common\events\order\AfterOrderReceivedImmediatelyEvent;
use app\common\models\Income;
use app\common\models\Order;
use app\common\services\income\IncomeService;
use Illuminate\Contracts\Events\Dispatcher;
use Yunshop\VideoShare\common\model\Bonus;
class OrderReceiveListener
{
public function subscribe(Dispatcher $events)
{
$events->listen(AfterOrderReceivedImmediatelyEvent::class, self::class . '@onHandle');
}
public function onHandle(AfterOrderReceivedImmediatelyEvent $event)
{
$order_id = $event->getOrderModel()->id;
\Log::debug('视频分享插件收货监听开始',$order_id);
// file_put_contents(storage_path('logs/pplla.txt'), print_r(date('Ymd His').'视频-订单完成'.PHP_EOL,1), FILE_APPEND);
$order = Order::find($order_id);
$videoBonus = Bonus::select()
->where('order_id', $order->id)
->where('status', 0)
->first();
// file_put_contents(storage_path('logs/pplla.txt'), print_r(date('Ymd His').'视频-订单完成orderid:'.$order->id.PHP_EOL,1), FILE_APPEND);
if ($videoBonus) {
$videoBonus->status = 1;
$videoBonus->save();
$this->income($videoBonus);
\Log::debug('视频分享插件收货监听结束',$order_id);
// file_put_contents(storage_path('logs/pplla.txt'), print_r(date('Ymd His').'视频-结算:'.json_encode($videoBonus, 256).PHP_EOL,1), FILE_APPEND);
}
}
public function income($videoBonus)
{
// 收入
$store_income_data = [
'uniacid' => $videoBonus->uniacid,
'member_id' => $videoBonus->uid,
'incometable_type' => Bonus::class,
'dividend_code' => IncomeService::VIDEO_SHARE_BONUS,
'dividend_table_id' => $videoBonus->id,
'type_name' => '发现视频奖励',
'amount' => $videoBonus->amount,
'status' => 0,
'pay_status' => 0,
'detail' => '',
'create_month' => date('Y-m', time())
];
// file_put_contents(storage_path('logs/pplla.txt'), print_r(date('Ymd His').'视频-收入:'.json_encode($store_income_data, 256).PHP_EOL,1), FILE_APPEND);
IncomeService::insertIncome($store_income_data);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace Yunshop\VideoShare\common\listeners;
use app\common\services\SystemMsgService;
use Illuminate\Contracts\Events\Dispatcher;
use Yunshop\VideoShare\common\events\VideoPublishEvent;
class VideoPublishListener
{
public function subscribe(Dispatcher $events)
{
$events->listen(VideoPublishEvent::class, self::class . '@handle');
}
public function handle(VideoPublishEvent $events)
{
$video = $events->getVideo();
if ($video->status == 1) {
return;
}
//【系统消息通知】
(new SystemMsgService())->applyNotice($video,'video-share');
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace Yunshop\VideoShare\common\member;
use app\frontend\modules\member\services\MemberCenterPluginBaseService;
use Yunshop\VideoShare\common\model\VideoShareGoods;
/**
* Class MemberCenterVideoShare
* @package Yunshop\VideoShare\common\member
*/
class MemberCenterVideoShare extends MemberCenterPluginBaseService
{
public function getEnabled()
{
$set = \Setting::get('plugin.video-share');
if (empty($set) || empty($set['is_open'])) {
return false;
}
$count = $this->getRedis('member_center_video_share_'.\Yunshop::app()->uniacid);
if (is_null($count)) {
$count = VideoShareGoods::uniacid()
->where('status', 1)
->count();
$this->setRedis('member_center_video_share_'.\Yunshop::app()->uniacid,($count?:0));
}
if ($count > 0) {
return true;
}
return false;
}
public function getData()
{
return [];//本来这里返回数据的,但改为用原来的列表接口
}
}

View File

@ -0,0 +1,92 @@
<?php
namespace Yunshop\VideoShare\common\member;
use app\frontend\modules\member\services\MemberCenterPluginBaseService;
use Yunshop\BusinessCard\common\models\BusinessCardModel;
use Yunshop\VideoShare\common\model\Follow;
use Yunshop\VideoShare\common\model\LikeLog;
use Yunshop\VideoShare\common\model\VideoShareGoods;
/**
* Class StoreMemberCenterVideoShare
* @package Yunshop\VideoShare\common\member
*/
class StoreMemberCenterVideoShare extends MemberCenterPluginBaseService
{
public function getEnabled()
{
$set = \Setting::get('plugin.video-share');
if (empty($set) || empty($set['is_open'])) {
return false;
}
$count = $this->getRedis('store_member_center_video_share');
if (is_null($count)) {
$count = VideoShareGoods::uniacid()
->where('status', 1)
->where('store_id',$this->request['store_id'])
->count();
$this->setRedis('store_member_center_video_share',($count?:0));
}
if ($count > 0) {
return true;
}
return false;
}
public function getData()
{
$uid = \YunShop::app()->getMemberId();
$list = VideoShareGoods::uniacid()
->with([
'member' => function ($query) {
$query->select('uid','nickname','avatar');
},
])
->where('status', 1)
->where('store_id',$this->request['store_id'])
->orderBy('id', 'desc')
->paginate(10)->toArray();
$businessCard = app('plugins')->isEnabled('business-card');
foreach ($list['data'] as &$item) {
$item['member']['avatar'] = yz_tomedia($item['member']['avatar']);
$item['cover'] = yz_tomedia($item['cover']);
$item['video'] = yz_tomedia($item['video']);
// 会员名片
$item['member']['business_card'] = 0;
if ($businessCard) {
$cardModel = BusinessCardModel::select()
->where('member_id', $item['member']['uid'])
->first();
if ($cardModel) {
$item['member']['business_card'] = $cardModel->id;
}
}
// 会员点赞 默认可以点赞
$item['member_like'] = 1;
$likeLog = LikeLog::select()
->where('uid', $uid)
->where('vid', $item['id'])
->first();
if ($likeLog) {
$item['member_like'] = 0;
}
$item['room_id'] = 0;
//判断是否关注
$follow = Follow::uniacid()->where("member_id",$item['uid'])->where("follow_member_id",$uid)->count();
$item['is_follow'] = ($follow>0) ? 1 : 0;
}
return $list;
}
}

View File

@ -0,0 +1,115 @@
<?php
namespace Yunshop\VideoShare\common\model;
use app\common\models\BaseModel;
use app\common\models\Member;
use app\common\models\Order;
use Illuminate\Database\Eloquent\Builder;
class Bonus extends BaseModel
{
public $table = 'yz_video_share_bonus';
public $timestamps = true;
protected $guarded = [''];
protected $appends = [
'status_name'
];
public static function getList($search)
{
return self::with([
'member' => function ($member) {
$member->select(['avatar', 'uid', 'nickname']);
},
'order' => function ($order) {
$order->select(['id', 'price', 'order_sn']);
},
'video' => function ($video) {
$video->select(['id', 'title']);
}
])->search($search);
}
public function scopeSearch($query, $search)
{
if ($search['vid']) {
$query->where('vid', $search['vid']);
}
if ($search['uid']) {
$query->where('uid', $search['uid']);
}
if ($search['member']) {
$query->whereHas('member', function ($member) use ($search) {
$member->select('uid', 'nickname', 'realname', 'mobile', 'avatar')
->where('realname', 'like', '%' . $search['member'] . '%')
->orWhere('mobile', 'like', '%' . $search['member'] . '%')
->orWhere('nickname', 'like', '%' . $search['member'] . '%');
});
}
if ($search['vtitle']) {
$query->whereHas('video', function ($video) use ($search) {
$video->select('id', 'title')
->where('title', 'like', '%' . $search['vtitle'] . '%');
});
}
if ($search['vgoods_id']) {
$query->whereHas('video', function ($video) use ($search) {
$video->select('id', 'title', 'goods_id')
->where('goods_id', $search['vgoods_id']);
});
}
if($search['is_time']){
if($search['time']){
$range = [$search['start_time'], $search['end_time']];
$query->whereBetween('created_at', $range);
}
}
return $query;
}
public function getStatusNameAttribute()
{
$statusName = '待结算';
if ($this->status == 1) {
$statusName = '已结算';
}
return $statusName;
}
public function member()
{
return $this->hasOne(Member::class, 'uid', 'uid');
}
public function order()
{
return $this->hasOne(Order::class, 'id', 'order_id');
}
public function video()
{
return $this->hasOne(VideoShareGoods::class, 'id', 'vid');
}
public function bonus()
{
return $this->hasMany(self::class, 'create_month', 'create_month');
}
public static function boot()
{
parent::boot();
static::addGlobalScope(function (Builder $builder) {
$builder->uniacid();
});
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Yunshop\VideoShare\common\model;
use app\common\models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;
class CategoryModel extends BaseModel
{
use SoftDeletes;
protected $table = "yz_video_share_category";
protected $guarded = [];
public static function scopeSearch($query,$search){
$model = $query->uniacid();
if (!empty($search['keyword'])) {
$model->where("id",$search['keyword'])->orWhere("name",$search['keyword']);
}
return $model;
}
}

View File

@ -0,0 +1,158 @@
<?php
namespace Yunshop\VideoShare\common\model;
use app\common\models\BaseModel;
use app\common\models\Member;
class Comment extends BaseModel
{
public $table = "yz_video_share_comment";
protected $guarded = [''];
protected $appends = ['type_name','comment_images','head_image'];
/**
* 状态
*/
const TYPE_COMMENT = 1;
const TYPE_REPLY = 2;
const TYPE_ADD_COMMENT = 3;
/**
* @var array
*/
public static $StatusComment = [
self::TYPE_COMMENT => '评论',
self::TYPE_REPLY => '回复',
self::TYPE_ADD_COMMENT => '追加评论',
];
public function getTypeNameAttribute()
{
return self::$StatusComment[$this->attributes['type']] ?: '追加回复';
}
public function getCommentImagesAttribute()
{
if($this->attributes['images'])
{
$images = unserialize($this->attributes['images']);
foreach ($images as &$image)
{
$image = yz_tomedia($image);
}
return $images;
}else{
return [];
}
}
public function getHeadImageAttribute()
{
if($this->attributes['head_img_url'])
{
return yz_tomedia($this->attributes['head_img_url']);
}else{
return '';
}
}
public static function getComments($search){
$merModel=self::uniacid();
if ($search['video_id']) {
$merModel->where('video_id',$search['video_id']);
}
if ($search['is_time']) {
if ($search['time']) {
$range = [strtotime($search['time']['start']), strtotime($search['time']['end'])];
$merModel->whereBetween('created_at', $range);
}
}
$merModel->with(['member' => function ($query) {
$query->select('uid', 'nickname', 'avatar');
}]);
$merModel->orderBy('created_at', 'desc')->orderBy('id', 'desc');
return $merModel;
}
/**
* @param $id
* @return mixed
*/
public static function getComment($id)
{
return self::with(['hasManyReply'=>function ($query) {
return $query->where('type', 2)
->orderBy('created_at', 'asc');
},'video' => function($q2){
return $q2->select('id','title');
},'member' => function ($query) {
$query->select('uid', 'nickname', 'avatar');
}])
->with(['hasManyAppend' => function ($query) {
return $query->where('type', 3)
->orderBy('created_at', 'asc');
}])
->where('id', $id);
}
public function member()
{
return $this->belongsTo(Member::class, 'uid', 'uid');
}
public function video()
{
return $this->belongsTo(VideoShareGoods::class, 'video_id', 'id');
}
public function hasManySupport()
{
return $this->hasMany(Support::class,'comment_id','id');
}
public function hasManyReply()
{
return $this->hasMany(self::class);
}
public function hasManyAppend()
{
return $this->hasMany(self::class);
}
/**
* 定义字段名
* 可使
* @return array
*/
public function atributeNames()
{
return [
'video_id' => '视频ID',
'content' => '评论内容',
];
}
/**
* 字段规则
* @return array
*/
public function rules()
{
return [
'video_id' => 'required',
'content' => 'required'
];
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace Yunshop\VideoShare\common\model;
use app\common\models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;
class Follow extends BaseModel
{
use SoftDeletes;
public $table = "yz_video_share_follow";
protected $guarded = [];
}

View File

@ -0,0 +1,15 @@
<?php
namespace Yunshop\VideoShare\common\model;
class Goods extends \app\common\models\Goods
{
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->pushAppends(['min_price']);
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Yunshop\VideoShare\common\model;
use app\common\models\BaseModel;
use Illuminate\Database\Eloquent\Builder;
class LikeLog extends BaseModel
{
public $table = 'yz_video_share_like_log';
public $timestamps = true;
protected $guarded = [''];
public static function boot()
{
parent::boot();
static::addGlobalScope(function (Builder $builder) {
$builder->uniacid();
});
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace Yunshop\VideoShare\common\model;
use app\common\models\BaseModel;
class Support extends BaseModel
{
public $table = "yz_video_comment_support";
protected $guarded = [''];
const STATUS_SUCCESS = 1;
const STATUS_FAIL = -1;
}

View File

@ -0,0 +1,129 @@
<?php
namespace Yunshop\VideoShare\common\model;
use app\common\models\BaseModel;
use app\common\models\Goods;
use app\common\models\Member;
use Illuminate\Database\Eloquent\Builder;
class VideoShareGoods extends BaseModel
{
public $table = 'yz_video_share_goods';
public $timestamps = true;
protected $guarded = [''];
protected $appends = ['video_src', 'comment_sum'];
public static function getList($search)
{
return self::uniacid()
->with([
'member' => function ($member) {
$member->select(['avatar', 'uid', 'nickname']);
},
'goods' => function ($goods) {
$goods->select(['id', 'title', 'price', 'market_price', 'thumb','has_option']);
}
])
->search($search);
}
public function scopeSearch($query, $search)
{
// 视频id
if ($search['id']) {
$query->where('id', $search['id']);
}
// 会员id
if ($search['uid']) {
$query->where('uid', $search['uid']);
}
//会员搜索
if ($search['member']) {
$query->whereHas('member', function ($member) use ($search) {
$member->select('uid', 'nickname', 'realname', 'mobile', 'avatar')
->where('realname', 'like', '%' . $search['member'] . '%')
->orWhere('mobile', 'like', '%' . $search['member'] . '%')
->orWhere('nickname', 'like', '%' . $search['member'] . '%');
});
}
// 标题
if ($search['title']) {
$query->where('title', 'like', '%' . $search['title'] . '%');
}
if ($search['goods_id']) {
$query->where('goods_id', $search['goods_id']);
}
if ($search['category_id']) {
$query->where("category_id",$search['category_id']);
}
if ($search['is_recommend']) {
$query->where("is_recommend",$search['is_recommend']);
}
//关注
if ($search['is_follow']) {
$member_id = \YunShop::app()->getMemberId();
$uids = Follow::uniacid()->where("follow_member_id",$member_id)->pluck("member_id");
$query->whereIn("uid",$uids);
}
// 时间搜索
if($search['is_time']){
if($search['time']){
$range = [$search['start_time'], $search['end_time']];
$query->whereBetween('created_at', $range);
}
}
return $query;
}
public function myVideo ($uid)
{
return self::uniacid()
->with([
'member' => function ($member) {
$member->select(['avatar', 'uid', 'nickname']);
},
'goods' => function ($goods) {
$goods->select(['id', 'title', 'price', 'market_price', 'thumb']);
}
])->where(['uid' => $uid]);
}
public function member()
{
return $this->hasOne(Member::class, 'uid', 'uid');
}
public function goods()
{
return $this->hasOne(\Yunshop\VideoShare\common\model\Goods::class, 'id', 'goods_id');
}
public static function boot()
{
parent::boot();
static::addGlobalScope(function (Builder $builder) {
$builder->uniacid();
});
}
public function getVideoSrcAttribute()
{
return $this->video?yz_tomedia($this->video):'';
}
public function getCommentSumAttribute()
{
$sum = Comment::where('video_id',$this->id)
->get()
->count();
return $sum;
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace Yunshop\VideoShare\common\model;
use app\common\models\BaseModel;
use app\common\models\Goods;
use app\common\models\Member;
use Illuminate\Database\Eloquent\Builder;
class VideoShareWatchRecord extends BaseModel
{
public $table = 'yz_video_share_watch_record';
public $timestamps = true;
protected $guarded = [''];
}

View File

@ -0,0 +1,123 @@
<?php
namespace Yunshop\VideoShare\common\pipe;
use app\backend\modules\goods\services\GoodsService;
use Closure;
use app\common\models\Goods;
use Yunshop\YzSupply\services\YzGoodsService;
use app\common\models\Category;
class GoodsCategoryProcess
{
public function handle($yz_goods, Closure $next)
{
$goods_model = YzGoodsService::$current_goods;
if (empty($yz_goods['local_category']) && $yz_goods['source'] != 6 && $goods_model instanceof Goods) {
$first_id = Category::uniacid()->pluginId()->where('level',1)->where('name',$yz_goods['category_1']['name'])->value('id');
//没有一级分类,直接创建三级
if (empty($first_id)) {
if ($yz_goods['category_1']['name']) {
$first_id = Category::insertGetId([
'uniacid' => \YunShop::app()->uniacid,
'name' => $yz_goods['category_1']['name'],
'parent_id' => 0,
'level' => 1,
'thumb' => $yz_goods['category_1']['image'],
'enabled' => 1,
'created_at' => time(),
'updated_at' => time()
]);
if ($yz_goods['category_2']['name']) {
$second_id = Category::insertGetId([
'uniacid' => \YunShop::app()->uniacid,
'name' => $yz_goods['category_2']['name'],
'parent_id' => $first_id,
'level' => 2,
'thumb' => $yz_goods['category_2']['image'],
'enabled' => 1,
'created_at' => time(),
'updated_at' => time()
]);
if (\Setting::get('shop.category')['cat_level'] == 3 && $yz_goods['category_3']['name']) {
$third_id = Category::insertGetId([
'uniacid' => \YunShop::app()->uniacid,
'name' => $yz_goods['category_3']['name'],
'parent_id' => $second_id,
'level' => 3,
'thumb' => $yz_goods['category_3']['image'],
'enabled' => 1,
'created_at' => time(),
'updated_at' => time()
]);
}
}
}
} else {
//有一级,没有二级。直接创建二级、三级
$second_id = Category::uniacid()->pluginId()->where('parent_id',$first_id)->where('level',2)->where('name',$yz_goods['category_2']['name'])->value('id');
if (empty($second_id)) {
if ($yz_goods['category_2']['name']) {
$second_id = Category::insertGetId([
'uniacid' => \YunShop::app()->uniacid,
'name' => $yz_goods['category_2']['name'],
'parent_id' => $first_id,
'level' => 2,
'thumb' => $yz_goods['category_2']['image'],
'enabled' => 1,
'created_at' => time(),
'updated_at' => time()
]);
if (\Setting::get('shop.category')['cat_level'] == 3 && $yz_goods['category_3']['name']) {
$third_id = Category::insertGetId([
'uniacid' => \YunShop::app()->uniacid,
'name' => $yz_goods['category_3']['name'],
'parent_id' => $second_id,
'level' => 3,
'thumb' => $yz_goods['category_3']['image'],
'enabled' => 1,
'created_at' => time(),
'updated_at' => time()
]);
}
}
} else {
if (\Setting::get('shop.category')['cat_level'] == 3 && $yz_goods['category_3']['name']) {
//有一级、二级,没有三级,创建三级
$third_id = Category::uniacid()->pluginId()->where('parent_id',$second_id)->where('level',3)->where('name',$yz_goods['category_3']['name'])->value('id');
if (empty($third_id)) {
$third_id = Category::insertGetId([
'uniacid' => \YunShop::app()->uniacid,
'name' => $yz_goods['category_3']['name'],
'parent_id' => $second_id,
'level' => 3,
'thumb' => $yz_goods['category_3']['image'],
'enabled' => 1,
'created_at' => time(),
'updated_at' => time()
]);
}
}
}
}
if ($first_id) {
$yz_goods['local_category']['parentid'][] = $first_id;
}
if (isset($second_id)) {
$yz_goods['local_category']['childid'][] = $second_id;
}
if (isset($third_id)) {
$yz_goods['local_category']['thirdid'][] = $third_id;
}
}
//属于导入或者有分类数据
if ($goods_model instanceof Goods || $yz_goods['local_category']) {
GoodsService::saveGoodsMultiCategory($goods_model, $yz_goods['local_category'], \Setting::get('shop.category'));
}
return $next($yz_goods);
}
}

View File

@ -0,0 +1,109 @@
<?php
namespace Yunshop\VideoShare\common\service;
use Yunshop\VideoShare\common\model\VideoShareGoods;
class CloudRequestService extends \Yunshop\YzSupply\services\CloudRequestService
{
private $goodsList = 'app/video/videoList'; //中台视频接口
private $goodsDetail = 'app/video/videoDetail'; //中台详情接口
private $addVideoStorage = 'app/video/addStorage'; //中台视频添加选品库接口
private $delVideoStorage = 'app/video/deleteStorage'; //中台视频删除选品库接口
public function goodsList($data, $isSplit = false)
{
$search = [];
$search['page'] = $data['page'] ?: 1;
$search['pageSize'] = $data['pageSize'] ?: 10;
if ($data['goods_import']) {
$search['is_import'] = (string)$data['goods_import'];
}
if ($data['id']) {
$search['id'] = (int)$data['id'];
}
if ($data['title']) {
$search['title'] = (string)$data['title'];
}
if ($data['product_title']) {
$search['product_title'] = (string)$data['product_title'];
}
$result = $this->YzNewClient($this->goodsList, $search, 'post');
if ($result['code']) {
\Log::debug('中台短视频接口异常:', $result);
} else {
if ($isSplit) {
foreach ($result['data']['list'] as $key => $val) {
$result['data']['list'][$key]['origin_title'] = $val['title'];
$result['data']['list'][$key]['title'] = $this->titleSpilt($val['title']);
$result['data']['list'][$key]['product']['title'] = $this->titleSpilt($val['product']['title'],7);
}
}
$result['data']['total_page'] = (int)ceil($result['data']['total'] / $result['data']['pageSize']);
}
if(!count($result['data']['list'])){
$result['data']=['list'=>[]];
}
return $result;
}
public function goodsDetail($data)
{
$result = $this->YzNewClient($this->goodsDetail, ['ids' => $data], 'post');
if ($result['code']) {
\Log::debug('中台短视频接口异常:', $result);
}
return $result['data'];
}
public function addVideoStorage($data)
{
foreach ($data as $id) {
$result = $this->YzNewClient($this->addVideoStorage, ['product_id' => $id]);
if ($result['code']) {
\Log::debug('中台短视频接口异常:', $result);
}
}
}
public function delVideoStorage($data)
{
$result = $this->YzNewClient($this->delVideoStorage, ['ids' => $data]);
if ($result['code']) {
\Log::debug('中台短视频接口异常:', $result);
}
}
//标题三行显示,超出部分用省略号代替
private function titleSpilt($string, $limit = 15)
{
$result = [];
$len = mb_strlen($string);
$row = $len / $limit;
if ($row > 1) {
$result[] = mb_substr($string, 0, $limit);
if ($row <= 2) {
$result[] = mb_substr($string, $limit);
}
}
if ($row > 2) {
$result[] = mb_substr($string, $limit, $limit);
if ($row <= 3) {
$result[] = mb_substr($string, 2 * $limit);
}
}
if ($row > 3) {
$result[] = mb_substr($string, 2 * $limit, $limit) . '...';
}
if ($row < 1) {
$result = [$string];
}
return $result;
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace Yunshop\VideoShare\common\service;
class GoodsImportService extends \Yunshop\YzSupply\services\GoodsImportService
{
public function import($category, $yz_goods, $exits_goods ,$extra = [], $albumId = 0)
{
$yz_goods['local_category'] = $category;
$yz_goods['local_extra'] = $extra;
if ($goods_id = array_search($yz_goods['id'],$exits_goods)) {
return YzGoodsService::updateGoods($goods_id,$yz_goods, $albumId);
}
return YzGoodsService::createGoods($yz_goods);
}
}

View File

@ -0,0 +1,149 @@
<?php
namespace Yunshop\VideoShare\common\service;
use app\frontend\modules\finance\interfaces\IIncomePage;
use Yunshop\VideoShare\common\model\Bonus;
class IncomePageService implements IIncomePage
{
private $itemModel;
public function __construct()
{
$this->itemModel = $this->getItemModel();
}
/**
* 对应收入唯一标示
*
* return string
*/
public function getMark()
{
return 'icon-reward_record';
}
/**
* 系统设置是否显示
*
* @return bool
*/
public function isShow()
{
return \Setting::get('plugin.video-share.is_open') ? true : false;
}
/**
* 是否可用状态(属于更多权限或可用权限)
*
* @return bool
*/
public function isAvailable()
{
return $this->itemModel ? true : false;
}
/**
* 对应收入名称
*
* @return string
*/
public function getTitle()
{
return '发现视频';
}
/**
* 对应收入图标
* @return string
*/
public function getIcon()
{
return 'icon-reward_record';
}
/**
* 对应收入 type 字段 value
* @return string
*/
public function getTypeValue()
{
$uid = \YunShop::app()->getMemberId();
$amountTotal = Bonus::select()
->where('uid', $uid)
->where('status', 1)
->sum('amount');
return round($amountTotal, 2);
}
/**
* 对应收入 等级
* @return string
*/
public function getLevel()
{
return '';
}
//app 访问url
public function getAppUrl()
{
return 'VideoReward';
}
/**
* @return string
*/
public function getMiniUrl()
{
return '/packageC/video_goods/VideoReward/VideoReward';
}
/**
* 是否需要验证是推客true 需要false 不需要
* @return bool
*/
public function needIsAgent()
{
return false;
}
/**
* 是否需要验证开启关系链true 需要false 不需要
* @return bool
*/
public function needIsRelation()
{
return false;
}
/**
* @return mixed
*/
private function getItemModel()
{
$uid = \YunShop::app()->getMemberId();
$model = Bonus::select()
->where('uid', $uid)
->first();
if ($model) {
return $model;
}
return false;
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace Yunshop\VideoShare\common\service;
use app\common\services\member\center\BaseMemberCenterService;
use Yunshop\VideoShare\frontend\VideoController;
class MemberCenterService extends BaseMemberCenterService
{
public function getData(): array
{
$data = [];
$set = \Setting::get('plugin.video-share');
if ($set['is_open']) {
$data[] = [
'name' => 'video-share',
'title' => '发现视频',
'class' => 'icon-extension_video',
'url' => $set['list_style'] == 2 ? 'VideoDetail' : 'VideoList',
'image' => 'member_a(73).png',
'mini_url' => $set['list_style'] == 2 ? '/packageC/video_goods/VideoDetail/VideoDetail' : '/packageC/video_goods/VideoList/VideoList',
'type_1' => 'interactive',
'type_2' => 'market',
'weight_1' => 4600,
'weight_2' => 8600,
'default_weight' => 7
];
}
return $data;
}
public function getPluginData(): array
{
return [
[
'code' => 'videoShare',
'diy_code' => 'video-share',
'name' => '发现视频',
'sort' => 5,
'class' => __CLASS__
]
];
}
public function videoShare()
{
return (new VideoController())->getList()->getData()->data;
}
}

View File

@ -0,0 +1,122 @@
<?php
namespace Yunshop\VideoShare\common\service;
use app\common\models\MemberShopInfo;
use Illuminate\Support\Str;
use Yunshop\Hotel\common\models\Hotel;
use Yunshop\StoreCashier\common\models\Store;
use Yunshop\Supplier\common\models\Supplier;
use Yunshop\TeamDividend\models\TeamDividendAgencyModel;
class PermissionService
{
private $uid;
public $ret = false;
public function __construct($uid)
{
$this->uid = $uid;
$this->_int();
}
private function _int()
{
$set = \Setting::get('plugin.video-share');
foreach ($set['releaser'] as $funcName) {
$func = Str::camel(preg_replace("/\\d+/",'', $funcName));
$ret = $this->$func();
if ($ret) {
$this->ret = $ret;
break;
}
}
}
private function member()
{
return true;
}
private function agent()
{
$agent = MemberShopInfo::select()
->where('member_id', $this->uid)
->first();
if ($agent->is_agent == 1) {
return true;
}
return false;
}
private function teamDividend()
{
$teamDividend = app('plugins')->isEnabled('team-dividend');
if (!$teamDividend) {
return false;
}
$dividend = TeamDividendAgencyModel::select()
->where('uid', $this->uid)
->first();
if ($dividend) {
return true;
}
return false;
}
private function store()
{
$storePlugin = app('plugins')->isEnabled('store-cashier');
if (!$storePlugin) {
return false;
}
$store = Store::select()
->where('uid', $this->uid)
->first();
if ($store) {
return true;
}
return false;
}
private function hotel()
{
$hotelPlugin = app('plugins')->isEnabled('hotel');
if (!$hotelPlugin) {
return false;
}
$hotel = Hotel::select()
->where('uid', $this->uid)
->first();
if ($hotel) {
return true;
}
return false;
}
private function supplier()
{
$supplierPlugin = app('plugins')->isEnabled('supplier');
if (!$supplierPlugin) {
return false;
}
$supplier = Supplier::select()
->where('member_id', $this->uid)
->first();
if ($supplier) {
return true;
}
return false;
}
private function appointMember()
{
$memberUid = \Setting::get('plugin.video-share.releaserMember');
if(!empty($memberUid) && in_array($this->uid, $memberUid)){
return true;
}
return false;
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace Yunshop\VideoShare\common\service;
use Yunshop\VideoShare\common\model\VideoShareGoods;
class ShopService
{
public function getAccess($member_id)
{
$res = true;
$set = \Setting::get('plugin.video-share');
if($set['need_video'] != 1 || $set['is_open'] != 1) return $res;
$finder = VideoShareGoods::where('uid', $member_id)->first();
if($finder) return true;
return false;
}
}

View File

@ -0,0 +1,142 @@
<?php
namespace Yunshop\VideoShare\common\service;
use app\common\facades\Setting;
use app\common\models\UniAccount;
use Yunshop\VideoShare\common\model\VideoShareGoods;
use Yunshop\YzSupply\models\MiddlegroundConfiguration;
use Yunshop\YzSupply\models\YzGoods;
use Yunshop\YzSupply\services\GoodsImportService;
use Yunshop\YzSupply\services\YzGoodsService;
class TimedTaskImportService
{
public function handle()
{
\Log::debug('每日导入中台新增短视频任务开始');
if(!app('plugins')->isEnabled('yz-supply')){
\Log::debug('没有开启供应链插件,不导入中台短视频');
return false;
}
date_default_timezone_set('PRC');
$uniAccount = UniAccount::getEnable();
foreach ($uniAccount as $u) {
\YunShop::app()->uniacid = $u->uniacid;
$this->preAction($u->uniacid);
}
return true;
}
public function preAction($uniacid){
\YunShop::app()->uniacid = $uniacid;
Setting::$uniqueAccountId = $uniacid;
$set = \Setting::get('plugin.video-share');
if(!$set['auto_sync_mid_ground_video']||!$set['mid_ground_cate']||empty($set['mid_ground_source'])){
return false;
}
$categorySearch['video_id']=$set['mid_ground_cate'];
try {
$actvieMidGround=MiddlegroundConfiguration::uniacid()->whereIn('id',$set['mid_ground_source'])->where('status',1)->get()->toArray();
foreach($actvieMidGround as $val){
$this->updateVideo($val['id'],$set);
}
} catch (\Exception $e) {
\Log::debug('每日更新中台短视频任务异常', $e->getMessage());
}
}
private function updateVideo($configId,$set)
{
$search=['goods_import'=>1];
$list = (new CloudRequestService($configId))->goodsList($search);
$count = $list['data']['total'];
$pageSize=20;
if($count>10000) $count = 10000;//固定最大值2000
$all_page = (int)ceil($count / $pageSize);
$search['pageSize']=20;
for ($page = 1; $page <= $all_page; $page++) {
$search['page']=$page;
$response = (new CloudRequestService($configId))->goodsList($search);
if (empty($response) || $response['code'] > 0 || empty($response['data']['list'])) {
//如果没有供应链id 终止检验
$response['msg'] = !empty($response['msg']) ? $response['msg'] : 'API返回信息异常';
\Log::debug('供应链一键导入报错--API返回信息异常' . $configId, json_encode($response));
return true;
}
$list = $response['data']['list'];
$this->goodsImport($configId,$list);
$this->videoImport($configId,$list,$set);
}
}
//短视频关联商品导入商城
private function goodsImport($configId,$list){
$all_yz_goods_ids = array_unique(array_column($list, 'product_id'));
$import_service = new GoodsImportService();
$result = array_chunk($all_yz_goods_ids, 30);
YzGoodsService::setSet($configId);//设置使用那个供应链
//
$exits_goods = YzGoods::whereIn('yz_goods_id', $all_yz_goods_ids)->where("middleground_configuration_id", YzGoodsService::$config['id'])->pluck('yz_goods_id', 'goods_id')->toArray();
foreach ($result as $yz_goods_id) {
$res = YzGoodsService::addStorage($yz_goods_id, YzGoodsService::$config['id']);
//加入选品库失败 直接跳过
if ($res['code'] == 2) {
\Log::debug('供应链一键导入:加入选品库失败' . $configId, json_encode($res));
continue;
}
$goodsList = YzGoodsService::batchGetAllGoods($yz_goods_id, YzGoodsService::$config['id']);
foreach ($goodsList as $goods) {
try {
$result = $import_service->import([], $goods, $exits_goods, []); //todo 查询导入 同步 京东商品数据 到 商城商品表
} catch (\Exception $e) {
\Log::debug('供应链一键导入报错' . $configId, json_encode($goods));
}
}
}
}
//短视频数据导入
private function videoImport($configId,$list,$set){
$videoId=$set['mid_ground_cate'];
$memberId=$set['default_member_id'];
$all_yz_goods_ids = array_unique(array_column($list, 'product_id'));
$shopGoodsIds = YzGoods::uniacid()->whereIn('yz_goods_id', $all_yz_goods_ids)->pluck('goods_id', 'yz_goods_id')->toArray();
$videoData = [];
foreach ($list as $video) {
$videoData[] = [
'goods_id' => $shopGoodsIds[$video['product_id']],
'uniacid' => \YunShop::app()->uniacid,
'uid' => $memberId,
'title' => $video['title'],
'video' => $video['video_url'] ?: '',
'file_name' => '',
'cover' => $video['cover_url'] ?: '',
'share_num' => 0,
'like_num' => 0,
'order_price' => 0,
'amount_total' => 0,
'status' => 1,
'category_id' => $videoId ?: 0,
'created_at' => time(),
'updated_at' => time(),
'mid_ground_video_id' => $video['id'],
'mid_ground_config_id' => $configId
];
}
if (!empty($videoData)) {
(new CloudRequestService($configId))->addVideoStorage(array_column($list, 'id'));
VideoShareGoods::insert($videoData);
}
}
}

View File

@ -0,0 +1,92 @@
<?php
namespace Yunshop\VideoShare\common\service;
use app\common\exceptions\ShopException;
use app\common\facades\Setting;
use app\common\models\UniAccount;
use Yunshop\VideoShare\common\model\VideoShareGoods;
class TimedTaskService
{
public function handle()
{
\Log::debug('每日更新中台短视频任务开始');
if(!app('plugins')->isEnabled('yz-supply')){
\Log::debug('没有开启供应链插件,不更新中台短视频');
return false;
}
date_default_timezone_set('PRC');
$uniAccount = UniAccount::getEnable();
foreach ($uniAccount as $u) {
\YunShop::app()->uniacid = $u->uniacid;
$this->updateVideo($u->uniacid);
}
return true;
}
private function updateVideo($uniacid)
{
\YunShop::app()->uniacid = $uniacid;
Setting::$uniqueAccountId = $uniacid;
try {
$videoList=VideoShareGoods::uniacid()
->where([['mid_ground_video_id','>',0],['deleted_at','=',null]])
->select(['mid_ground_video_id','mid_ground_config_id','id','goods_id'])
->get();
$videoList=$videoList->groupBy('mid_ground_config_id')->toArray();
foreach($videoList as $key=>$val){
$service=(new CloudRequestService($key));
YzGoodsService::setSet($key);
foreach($val as $k=>$v){
$yzVideoDetail=$service->goodsDetail([$v['mid_ground_video_id']]);
$goods_model = \Yunshop\YzSupply\models\Goods::select('id', 'uniacid', 'status')->with('hasOneYzGoods')->find($v['goods_id']);
if (!$goods_model && !$goods_model->hasOneYzGoods) {
throw new ShopException('商品不存在或已被删除');
}
$updateGoods=0;
if($goods_model->hasOneYzGoods->yz_goods_id==$yzVideoDetail['product_id']){
$updateGoods=$goods_model->id;
}else{
$exist=\Yunshop\YzSupply\models\YzGoods::uniacid()->where(['middleground_configuration_id'=>$v['mid_ground_config_id'],'yz_goods_id'=>$yzVideoDetail['product_id']])->first();
if($exist){
$updateGoods=$exist->goods_id;
}
}
//商城中已存在的商品调用供应链更新商品方法,不存在的导入
if($updateGoods){
\Yunshop\YzSupply\services\YzGoodsService::updateGoods($updateGoods, \Yunshop\VideoShare\common\service\YzGoodsService::requestYz($yzVideoDetail['product_id'])['yz_goods']);
}else{
$errorGoodsIds=GoodsImportService::beforeImport([$yzVideoDetail['product_id']], [], [],$v['mid_ground_config_id']);
if (empty($errorGoodsIds)) {
$shopGoods=\Yunshop\YzSupply\models\YzGoods::uniacid()->where(['yz_goods_id'=>$yzVideoDetail['product_id'],'middleground_configuration_id'=>$v['mid_ground_config_id']])->first();
if($shopGoods){
$updateGoods=$shopGoods->goods_id;
}
}
}
VideoShareGoods::where('id',$v['id'])->update([
'title'=>$yzVideoDetail['title'],
'cover'=>$yzVideoDetail['cover_url'],
'video'=>$yzVideoDetail['video_url'],
'status'=>$yzVideoDetail['is_display'],
'goods_id'=>$updateGoods
]);
}
}
} catch (\Exception $e) {
\Log::debug('每日更新中台短视频任务异常', $e->getMessage());
}
}
}

View File

@ -0,0 +1,81 @@
<?php
namespace Yunshop\VideoShare\common\service;
use app\common\exceptions\ShopException;
use Illuminate\Pipeline\Pipeline;
use Yunshop\VideoShare\common\pipe\GoodsCategoryProcess;
use Yunshop\YzSupply\models\YzGoods;
use Yunshop\YzSupply\pipe\BrandProcess;
use Yunshop\YzSupply\pipe\GoodsOptionProcess;
use Yunshop\YzSupply\pipe\GoodsParamProcess;
use Yunshop\YzSupply\pipe\GoodsProcess;
use Yunshop\YzSupply\pipe\ImageProcess;
use Yunshop\YzSupply\pipe\PriceProcess;
use Yunshop\YzSupply\pipe\InvoiceProcess;
use Yunshop\YzSupply\models\Goods;
use Yunshop\YzSupply\services\CloudRequestService;
class YzGoodsService extends \Yunshop\YzSupply\services\YzGoodsService
{
//导入商品
public static function createGoods($yz_goods)
{
static::$current_goods = new Goods();
//管道处理
$pipes = [
// SelectionProcess::class,//加入选品库
ImageProcess::class,//图片处理
PriceProcess::class,//价格处理
BrandProcess::class,//品牌处理
GoodsProcess::class,//商品处理
GoodsCategoryProcess::class,//分类处理
GoodsParamProcess::class,//商品属性处理
GoodsOptionProcess::class,//商品规格处理
InvoiceProcess::class,//发票挂件处理 (分商品赋码以及规格赋码)
];
return (new Pipeline(app()))
->send($yz_goods)
->through($pipes)
->then(function () {
return true;
});
}
public static function requestYz($yz_goods_id)
{
$YzGoodsModel = YzGoods::where('yz_goods_id', $yz_goods_id)->first();
if (!$YzGoodsModel) {
return false;
}
if (empty($YzGoodsModel['middleground_configuration_id'])) {
throw new ShopException('商品没有绑定供应链');
}
$data['ids'] = [$yz_goods_id];
$data['ids'] = array_map('intval', $data['ids']);
$data = (new CloudRequestService($YzGoodsModel['middleground_configuration_id']))->getProductDetail($data);
$yz_goods = $data['data']['list'][0];
if (empty($data) || $data['code'] > 0) {
return false;
}
if (empty($yz_goods)){
$delete = $yz_goods_id;
}
return [
'goods_id' => $YzGoodsModel->goods_id,
'yz_goods' => $yz_goods,
'delete'=>$delete,
];
}
}

View File

@ -0,0 +1,87 @@
<?php
namespace Yunshop\VideoShare\frontend;
use app\common\components\ApiController;
use app\common\models\Member;
use Illuminate\Support\Facades\DB;
use Yunshop\VideoShare\common\model\Bonus;
use Yunshop\VideoShare\common\model\VideoShareGoods;
class BonusController extends ApiController
{
// plugin.video-share.frontend.bonus.statistic
public function statistic()
{
$uid = \YunShop::app()->getMemberId();
// $uid = 68;
$member = Member::select(['avatar', 'uid', 'nickname'])
->where('uid', $uid)
->first();
$videoTotal = VideoShareGoods::select()
->where('uid', $uid)
->count();
$finishAmount = Bonus::select()
->where('uid', $uid)
->where('status', 1)
->sum('amount');
$waitAmount = Bonus::select()
->where('uid', $uid)
->where('status', 0)
->sum('amount');
return $this->successJson('成功', [
'member' => $member,
'video_total' => $videoTotal,
'finish_amount' => $finishAmount,
'wait_amount' => $waitAmount
]);
}
// plugin.video-share.frontend.bonus.getList
public function getList()
{
$uid = \YunShop::app()->getMemberId();
$list = Bonus::select('create_month')
->groupBy('create_month')
->where('uid', $uid)
->orderBy('create_month', 'desc')->paginate();
if(empty($list)){
return $this->errorJson('暂无数据');
}
foreach($list as $key => $value){
$data = Bonus::uniacid()
->with([
'member' => function ($member) {
$member->select(['avatar', 'uid', 'nickname']);
},
'order' => function ($order) {
$order->select(['id', 'price', 'order_sn']);
},
'video' => function ($video) {
$video->select(['id', 'title']);
},
])
->where('create_month',$value['create_month'])
->orderBy('id', 'desc')
->where('uid',$uid)
->get();
if(empty($data)){
continue;
}
$list[$key]['bonus'] = $data;
}
return $this->successJson('成功', [
'list' => $list
]);
}
}

View File

@ -0,0 +1,329 @@
<?php
namespace Yunshop\VideoShare\frontend;
use app\common\components\ApiController;
use app\common\exceptions\AppException;
use app\common\facades\Setting;
use app\common\models\Member;
use app\common\services\MiniFileLimitService;
use Illuminate\Support\Facades\DB;
use Yunshop\VideoShare\common\model\Comment;
use Yunshop\VideoShare\common\model\Support;
use Yunshop\VideoShare\common\model\VideoShareGoods;
class CommentController extends ApiController
{
public function preAction()
{
parent::preAction();
$set = Setting::get('plugin.video-share');
if ($set['is_open_comment'] != 1) {
throw new AppException('评论功能已关闭');
};
}
/**
* @return \Illuminate\Http\JsonResponse
* 文章评论列表
*/
public function commentList()
{
$video_id = \YunShop::request()->video_id;
$num = Comment::uniacid()
->where(['video_id' => $video_id, 'comment_id' => 0])
->count();
$finder = VideoShareGoods::uniacid()->find($video_id);
if(!$finder)
{
throw new AppException('不存在的视频');
}
$model = Comment::uniacid()
->with(['hasManyReply', 'hasManySupport' => function ($q) {
$q->where(['member_id' => \YunShop::app()->getMemberId(), 'status' => 1]);
}])
->where(['video_id' => $video_id, 'comment_id' => 0])
->orderBy('created_at', 'desc')
->orderBy('id', 'desc')
->paginate('', ['*'], '', (int)request()->page ?: 1);
$model = $model->toArray();
$model['data'] = collect($model['data'])->map(function ($item) use ($finder){
$num = count($item['has_many_reply']);
unset($item['has_many_reply']);
$is_support = 0;
if($item['has_many_support'])
{
$is_support = 1;
}
$can_del = 0;
if($finder->uid == \YunShop::app()->getMemberId() || $item['uid'] == \YunShop::app()->getMemberId()){
$can_del = 1;
}
$collection = collect($item)
->put('reply_num', $num)
->put('append_arr',[])
->put('can_del',$can_del)
->put('is_support',$is_support);
return $collection;
});
$member = Member::where('uid', \YunShop::app()->getMemberId())
->select(['uid', 'avatar', 'nickname'])->first();
return $this->successJson('ok', ['list' => $model, 'member' => $member, 'num' => $num]);
}
public function getVideoType()
{
$video_type = Setting::get('plugin.video-share')['video_type'] ?? 2;
return $this->successJson('ok', $video_type);
}
/**
* @return \Illuminate\Http\JsonResponse
* 查看回复
*/
public function getReplys()
{
$comment_id = \YunShop::request()->comment_id;
$comment = Comment::uniacid()->find($comment_id);
if (!$comment || $comment->comment_id != 0) {
return $this->errorJson('未检测到数据!');
}
$finder = VideoShareGoods::uniacid()->find($comment->video_id);
if(!$finder)
{
throw new AppException('不存在的视频');
}
$model = Comment::uniacid()
->where('comment_id', $comment_id)
->with(['hasManySupport' => function ($q) {
$q->where(['member_id' => \YunShop::app()->getMemberId(), 'status' => 1]);
}])
->orderBy('created_at', 'desc')
->orderBy('id', 'desc')
->paginate(5, ['*'], '', (int)request()->page ?: 1);
$model = $model->toArray();
$model['data'] = collect($model['data'])->map(function ($item) use ($finder){
$is_support = 0;
if($item['has_many_support'])
{
$is_support = 1;
}
$can_del = 0;
if($finder->uid == \YunShop::app()->getMemberId() || $item['uid'] == \YunShop::app()->getMemberId()){
$can_del = 1;
}
$collection = collect($item)
->put('can_del',$can_del)
->put('is_support',$is_support);
return $collection;
});
return $this->successJson('ok', $model);
}
public function createComment()
{
$commentModel = new Comment();
$ingress = request()->ingress;
$member = Member::getUserInfos(\YunShop::app()->getMemberId())->first();
if (!$member) {
return $this->errorJson('评论失败!未检测到会员数据!');
}
$commentStatus = '1';
$comment = [
'video_id' => \YunShop::request()->video_id,
'content' => \YunShop::request()->content,
];
if ($ingress && !empty($comment['content'])) {
$check_result = (new MiniFileLimitService())->checkMsg($comment['content']);
if ($check_result['errcode'] != 0) {
return $this->errorJson('输入信息含有违法违规内容');
}
}
if (!$comment['video_id']) {
return $this->errorJson('评论失败!未检测到文章ID!');
}
if (!$comment['content']) {
return $this->errorJson('评论失败!未检测到评论内容!');
}
if (\YunShop::request()->images) {
$comment['images'] = json_decode(\YunShop::request()->images);
if (is_array($comment['images'])) {
if (count($comment['images']) > 5) {
return $this->errorJson('追加评论失败!评论图片不能多于5张!');
}
$comment['images'] = serialize($comment['images']);
} else {
return $this->errorJson('追加评论失败!评论图片数据不正确!');
}
} else {
$comment['images'] = serialize([]);
}
$commentModel->setRawAttributes($comment);
$commentModel->uniacid = \YunShop::app()->uniacid;
$commentModel->nick_name = $member->nickname;
$commentModel->uid = $member->uid;
$commentModel->head_img_url = $member->avatar;
$commentModel->type = '1';
$res = $this->insertComment($commentModel, $commentStatus);
return $res;
}
public function replyComment()
{
$commentModel = new Comment();
$member = Member::getUserInfos(\YunShop::app()->getMemberId())->first();
if (!$member) {
return $this->errorJson('回复评论失败!未检测到会员数据!');
}
$id = \YunShop::request()->comment_id;
$reply = $commentModel::uniacid()->find($id);
if (!$reply) {
return $this->errorJson('回复评论失败!未检测到评论数据!');
}
$comment = [
'video_id' => $reply->video_id,
'content' => \YunShop::request()->content,
'comment_id' => $reply->comment_id ? $reply->comment_id : $reply->id,
];
if (!$comment['content']) {
return $this->errorJson('回复评论失败!未检测到评论内容!');
}
if (\YunShop::request()->images) {
$comment['images'] = json_decode(\YunShop::request()->images);
if (is_array($comment['images'])) {
if (count($comment['images']) > 5) {
return $this->errorJson('追加评论失败!评论图片不能多于5张!');
}
$comment['images'] = serialize($comment['images']);
} else {
return $this->errorJson('追加评论失败!评论图片数据不正确!');
}
} else {
$comment['images'] = serialize([]);
}
$commentModel->setRawAttributes($comment);
$commentModel->uniacid = \YunShop::app()->uniacid;
$commentModel->uid = $member->uid;
$commentModel->nick_name = $member->nickname;
$commentModel->head_img_url = $member->avatar;
if ($reply->comment_id) {
$commentModel->reply_id = $reply->uid;
$commentModel->reply_name = $reply->nick_name;
} else {
$commentModel->reply_id = 0;
$commentModel->reply_name = null;
}
$commentModel->reply_comment_id = $id;
$commentModel->type = '2';
return $this->insertComment($commentModel);
}
public function del()
{
//主评论不关联删除子评论。没人有权删除别人的评论,一直存在
$id = \YunShop::request()->comment_id;
$comment = Comment::uniacid()->find($id);
$video = VideoShareGoods::uniacid()->find($comment->video_id);
if (!$comment || !$video) {
return $this->errorJson('评论不存在');
}
if($comment->uid != \YunShop::app()->getMemberId() && $video->uid != \YunShop::app()->getMemberId())
{
return $this->errorJson('无删除权限');
}
$comment->delete();
return $this->successJson('ok', '删除成功');
}
public function support()
{
$comment_id = \YunShop::request()->comment_id;
$ReliableModel = Support::uniacid()->where(['comment_id' => $comment_id, 'member_id' => \YunShop::app()->getMemberId()])->first();
DB::beginTransaction();
try {
if ($ReliableModel) {
if ($ReliableModel->status == Support::STATUS_SUCCESS) {
$ReliableModel->status = Support::STATUS_FAIL;
$ReliableModel->save();
$this->changeSupport($comment_id, -1);
} elseif ($ReliableModel->status == Support::STATUS_FAIL) {
$ReliableModel->status = Support::STATUS_SUCCESS;
$ReliableModel->save();
$this->changeSupport($comment_id, 1);
}
} else {
$arr = [
'uniacid' => \YunShop::app()->uniacid,
'comment_id' => $comment_id,
'member_id' => \YunShop::app()->getMemberId(),
'status' => Support::STATUS_SUCCESS
];
$model = new Support;
$model->fill($arr);
$model->save();
$this->changeSupport($comment_id, 1);
}
DB::commit();
return $this->successJson('ok', '成功');
} catch (\Exception $e) {
DB::rollBack();
return $this->errorJson($e->getMessage());
}
}
private function insertComment($commentModel, $commentStatus = '')
{
$validator = $commentModel->validator($commentModel->getAttributes());
if ($validator->fails()) {
//检测失败
return $this->errorJson($validator->messages());
} else {
//数据保存
if ($commentModel->save()) {
return $this->successJson('评论成功!', $commentModel);
} else {
return $this->errorJson('评论失败!');
}
}
}
private function changeSupport($comment_id, $num)
{
$comment = Comment::uniacid()->find($comment_id);
if ($comment) {
$res = bcadd($comment->support_num, $num);
if($res < 0)
{
return;
}
$comment->support_num = $res;
$comment->save();
}
}
}

View File

@ -0,0 +1,96 @@
<?php
namespace Yunshop\VideoShare\frontend;
use app\common\components\ApiController;
use app\common\models\Goods;
use Yunshop\StoreCashier\common\models\Store;
use Yunshop\StoreCashier\store\models\GoodsStore;
class goodsController extends ApiController
{
// 添加商品 搜索 返回列表
// plugin.video-share.frontend.goods.getGoodsByKeyword
public function getGoodsByKeyword()
{
$keyword = request()->keyword;
if (!$keyword) {
return $this->errorJson('请输入关键词');
}
$goods_model = Goods::uniacid()->select('id', 'title', 'thumb', 'market_price', 'price','has_option')
->where('title', 'like', '%' . $keyword . '%')
->where('status', 1)
->whereIn('plugin_id', [0,32,33,44,92,57,58,101,120,154]);
//隐藏不显示门店的商品
if(app('plugins')->isEnabled('store-cashier')){
$store_ids = Store::uniacid()->where('is_hide', 1)->has('hasManyGoods')->pluck('id');
if($store_ids){
$store_goods_ids = GoodsStore::whereIn('store_id',$store_ids)->pluck('goods_id');
if($store_goods_ids){
$goods_model->whereNotIn('id', $store_goods_ids);
}
}
}
$list = $goods_model->paginate();
$list->map(function ($item) {
$thumb = yz_tomedia($item->thumb);
$item->thumb = $thumb;
if ($item->has_option && $item->hasManyOptions) {
$item->price = $item->hasManyOptions->min('product_price');
}
});
return $this->successJson('成功', [
'list' => $list
]);
}
// plugin.video-share.frontend.goods.getRecommendGoods
//120供应链,57应用市场,58应用市场子平台,140卡券商品,71聚合CPS品牌券商品,101门店预约商品,103电子合同,113多门店核销商品,130分时预约商品,154周边游商品
public function getRecommendGoods()
{
$list = \app\frontend\modules\goods\models\Goods::uniacid()
->select('id', 'id as goods_id', 'title', 'thumb', 'price', 'market_price','has_option')
->where('is_recommand', '1')
->whereIn('plugin_id', [0,32,33,44,92,57,58,120,140,71,101,103,113,130,154])
->whereStatus('1')
->orderBy('id', 'desc')
->paginate();
$list->map(function ($item) {
$thumb = yz_tomedia($item->thumb);
$item->thumb = $thumb;
if ($item->has_option && $item->hasManyOptions) {
$item->price = $item->hasManyOptions->min('product_price');
}
});
return $this->successJson('获取推荐商品成功', [
'list' => $list
]);
}
// 发布-选择商品后 回显
// plugin.video-share.frontend.goods.getGoodsById
public function getGoodsById()
{
$goodsId = intval(request()->goods_id);
if (!$goodsId) {
return $this->errorJson('参数错误[goods_id=null]');
}
$goods = Goods::uniacid()->select('id', 'title', 'thumb', 'market_price', 'price','has_option')
->find($goodsId);
$goods->thumb = yz_tomedia($goods->thumb);
$goods->append('min_price');
return $this->successJson('成功', [
'goods' => $goods
]);
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace Yunshop\VideoShare\frontend;
use app\common\components\ApiController;
use Yunshop\VideoShare\common\service\PermissionService;
class permissionController extends ApiController
{
// 验证会员发布权限
// plugin.video-share.frontend.permission.verify
public function verify()
{
$uid = \YunShop::app()->getMemberId();
$permissionService = new PermissionService($uid);
if ($permissionService->ret) {
$msg = '权限通过';
} else {
$msg = '您没有权限发布小视频';
}
return $this->successJson($msg, [
'ret' => $permissionService->ret
]);
}
}

View File

@ -0,0 +1,78 @@
<?php
namespace Yunshop\VideoShare\frontend;
use app\backend\modules\order\services\models\ExcelModel;
use app\common\components\ApiController;
class SetController extends ApiController
{
// 限制时长
// plugin.video-share.frontend.set.getLimit
public function getLimit()
{
$set = \Setting::get('plugin.video-share');
return $this->successJson('成功', [
'limit' => $set['limit'],
'select_goods' => !isset($set['select_goods'])?1:$set['select_goods'],
'is_show_cate' => empty($set['is_show_cate']) ? 0 : $set['is_show_cate'],
'default_title' => $set['default_title']?true:false,
'default_cate' => $set['default_cate']?true:false,
'must_video' => $set['must_video'] == 1?true:false,
'upload_button' => $set['upload_button'] ?: '确认发布',
'notice' => $set['notice'],
'diy_title' => $set['diy_title'] ?: '用户协议'
]);
}
// 获取协议
// plugin.video-share.frontend.set.getAgreement
public function getAgreement()
{
$set = \Setting::get('plugin.video-share');
return $this->successJson('成功', [
'agreement' => html_entity_decode($set['content'])
]);
}
// 获取背景
public function getBackground()
{
$set = \Setting::get('plugin.video-share');
return $this->successJson('成功', [
'background' => yz_tomedia($set['bgImg'])
]);
}
// 获取幻灯片
public function getSlide()
{
$set = \Setting::get('plugin.video-share');
return $this->successJson('成功', [
'slide' => [
[
'img' => yz_tomedia($set['banOne']),
'url' => $set['linkOne'],
'wxUrl' => $set['proOne'],
],
[
'img' => yz_tomedia($set['banTwo']),
'url' => $set['linkTwo'],
'wxUrl' => $set['proTwo'],
],
[
'img' => yz_tomedia($set['banThree']),
'url' => $set['linkThree'],
'wxUrl' => $set['proThree'],
]
],
'is_rotation' => $set['is_rotation']
]);
}
}

View File

@ -0,0 +1,144 @@
<?php
namespace Yunshop\VideoShare\frontend;
use app\common\components\ApiController;
use app\common\services\ImageZip;
use app\platform\modules\system\models\SystemSetting;
class UploadController extends ApiController
{
// plugin.video-share.frontend.upload.upload
public function uploadAudio()
{
$file = request()->file('file');
if (!$file) {
return $this->errorJson('请传入正确参数');
}
if (!$file->isValid()) {
return $this->errorJson('上传失败.');
}
// 获取文件相关信息
$originalName = $file->getClientOriginalName(); // 文件原名
$realPath = $file->getRealPath(); //临时文件的绝对路径
$ext = $file->getClientOriginalExtension();
$defaultImgType = [
'jpg', 'bmp', 'eps', 'gif', 'mif', 'miff', 'png', 'tif',
'tiff', 'svg', 'wmf', 'jpe', 'jpeg', 'dib', 'ico', 'tga', 'cut', 'pic'
];
$defaultAudioType = ['avi', 'asf', 'wmv', 'avs', 'flv', 'mkv', 'mov', '3gp', 'mp4',
'mpg', 'mpeg', 'dat', 'ogm', 'vob', 'rm', 'rmvb', 'ts', 'tp', 'ifo', 'nsv'
];
$defaultVideoType = [
'mp3', 'aac', 'wav', 'wma', 'cda', 'flac', 'm4a', 'mid', 'mka', 'mp2',
'mpa', 'mpc', 'ape', 'ofr', 'ogg', 'ra', 'wv', 'tta', 'ac3', 'dts'
];
$merge_ext = array_merge($defaultImgType, $defaultAudioType, $defaultVideoType);
if (!in_array(strtolower($ext), $merge_ext)) {
return $this->errorJson('非规定类型的文件格式');
}
$newOriginalName = md5($originalName . str_random(6)) . '.' . $ext;
if (config('app.framework') == 'platform') {
$remote = SystemSetting::settingLoad('remote', 'system_remote');
//本地上传
$result = \Storage::disk('newimages')->put($newOriginalName, file_get_contents($realPath));
if (!$result){
return $this->successJson('上传失败');
}
$url = \Storage::disk('newimages')->url($newOriginalName);
//图片审核
if(app('plugins')->isEnabled('upload-verification')){
$uploadReuslt = do_upload_verificaton(yz_tomedia($url), 'video');
if(0 === $uploadReuslt[0]['status']){
return $this->errorJson($uploadReuslt[0]['msg']);
}
}
//远程上传
if ($remote['type'] != 0) {
file_remote_upload_new($url, true, $remote);
}
return $this->successJson('上传成功', [
'file_name' => $newOriginalName,
'audio' => $url,
'audio_url' => yz_tomedia($url)
]);
} else {
//全局配置
global $_W;
//公众号独立配置信息 优先使用公众号独立配置
$uni_setting = app('WqUniSetting')->get()->toArray();
if (!empty($uni_setting['remote']) && iunserializer($uni_setting['remote'])['type'] != 0) {
$setting['remote'] = iunserializer($uni_setting['remote']);
$remote = $setting['remote'];
} else {
$remote = $_W['setting']['remote'];
}
//本地上传
$result = \Storage::disk('image')->put($newOriginalName, file_get_contents($realPath));
if (!$result) {
return $this->errorJson('上传失败');
}
$audio = \Storage::disk('image')->url($newOriginalName);
//图片审核
if(app('plugins')->isEnabled('upload-verification')){
$uploadReuslt = do_upload_verificaton(yz_tomedia($audio), 'video');
if(0 === $uploadReuslt[0]['status']){
return $this->errorJson($uploadReuslt[0]['msg']);
}
}
//远程上传
if ($remote['type'] != 0) {
file_remote_upload_wq($audio, true, $remote, true);
}
return $this->successJson('上传成功', [
'file_name' => $newOriginalName,
'audio' => $audio,
'audio_url' => yz_tomedia($audio)
]);
}
}
public function upload()
{
$file = request()->file('file');
if (!$file) {
return $this->errorJson('请传入正确参数');
}
if ($file->isValid()) {
// 获取文件相关信息
$originalName = $file->getClientOriginalName(); // 文件原名
$realPath = $file->getRealPath(); //临时文件的绝对路径
$ext = $file->getClientOriginalExtension();
$newOriginalName = md5($originalName . str_random(6)) . '.' . 'png';
\Storage::disk('image')->put($newOriginalName, file_get_contents($realPath));
return $this->successJson('上传成功', [
'img' => \Storage::disk('image')->url($newOriginalName),
'img_url' => upload_image_local(\Storage::disk('image')->url($newOriginalName)),
]);
}
}
}

View File

@ -0,0 +1,584 @@
<?php
namespace Yunshop\VideoShare\frontend;
use app\common\components\ApiController;
use app\common\facades\Setting;
use app\common\services\MiniFileLimitService;
use app\common\services\Utils;
use app\framework\Http\Request;
use app\frontend\models\Member;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Storage;
use Yunshop\BusinessCard\common\models\BusinessCardModel;
use Yunshop\VideoShare\common\events\VideoWatchEvent;
use Yunshop\VideoShare\common\model\CategoryModel;
use Yunshop\VideoShare\common\model\Comment;
use Yunshop\VideoShare\common\model\Follow;
use Yunshop\VideoShare\common\model\LikeLog;
use Yunshop\VideoShare\common\model\VideoShareGoods;
use Yunshop\VideoShare\common\model\VideoShareWatchRecord;
use Yunshop\VideoShare\common\events\VideoPublishEvent;
class VideoController extends ApiController
{
// 发现 列表
public function getList()
{
$uid = \YunShop::app()->getMemberId();
$search = request()->search;
//兼容APP请求
if (!is_array($search)) {
$search =[$search => 1];
}
$list = VideoShareGoods::getList($search)
->where('status', 1)
->orderBy('id', 'desc')
->paginate();
$businessCard = app('plugins')->isEnabled('business-card');
$list->map(function ($item) use ($businessCard, $uid) {
// 图片
$item->goods->thumb = yz_tomedia($item->goods->thumb);
if ($item->goods->has_option) {
$item->goods->price = $item->goods->hasManyOptions->min('product_price');
}
$item->member->avatar = yz_tomedia($item->member->avatar);
$item->cover = yz_tomedia($item->cover);
$item->video = yz_tomedia($item->video);
// 会员名片
$item->member->business_card = 0;
if ($businessCard) {
$cardModel = BusinessCardModel::select()
->where('member_id', $item->member->uid)
->first();
if ($cardModel) {
$item->member->business_card = $cardModel->id;
}
}
// 会员点赞 默认可以点赞
$item->member_like = 1;
$likeLog = LikeLog::select()
->where('uid', $uid)
->where('vid', $item->id)
->first();
if ($likeLog) {
$item->member_like = 0;
}
$item->room_id = 0;
//判断是否关注
$follow = Follow::uniacid()->where("member_id",$item->uid)->where("follow_member_id",$uid)->count();
$item->is_follow = ($follow>0) ? 1 : 0;
//评论
$comment_num = Comment::uniacid()
->where(['video_id' => $item->id, 'comment_id' => 0])
->count();
$item->comment_num = $comment_num;
//判断当前会员是否在直播
$item ->is_live = 0;
if (app('plugins')->isEnabled('room')) {
$anchor = \Yunshop\Room\models\Anchor::uniacid()->where("member_id",$item->uid)->first();
if ($anchor) {
$item->is_live = $anchor['status'];
}
$item->room_id = \Yunshop\Room\models\Room::uniacid()->where("status",3)->value("id");
}
//投放广告视频插件-观看赚/投放广告按钮
$item->ad_serving_button_status = [];
if (app('plugins')->isEnabled('ad-serving')) {
$item->ad_serving_button_status = \Yunshop\AdServing\services\PrivilegeValidateService::checkButton($item->id,2);
}
// 统计会员持有视频总数
$item->member_video_num = count(VideoShareGoods::where('uid', $item->uid)->whereNotNull('video')->get());
});
$video_redpack=['is_open'=>0,'data'=>[]];
if (app('plugins')->isEnabled('video-redpack')){
$video_redpack['is_open'] = 1;
$video_redpack['data']=\Yunshop\VideoRedpack\services\ActivityService::getActiviyForFrontend();
}
$set = \Setting::get('plugin.video-share');
return $this->successJson('成功', [
'list' => $list,
'is_plugins' => app('plugins')->isEnabled('answer-reward'),
'points_plugin' => app('plugins')->isEnabled('video-share-points'),
'video_redpack'=>$video_redpack,
'comment_open' => $set['is_open_comment']?:0
]);
}
//获取基础设置
public function getBasicSet()
{
$set = \Setting::get('plugin.video-share');
$setting['is_show_cate'] = $set['is_show_cate'];
$setting['is_show_own_follow'] = $set['is_show_own_follow'];
$setting['is_show_recommend'] = $set['is_show_recommend'];
$setting['is_show_live'] = $set['is_show_live'];
$setting['topLike'] = $set['topLike'] ?: "";
$setting['topSmileLike'] = $set['topSmileLike'];
$setting['customIcon'] = empty($set['customIcon']) ? "" : yz_tomedia($set['customIcon']);
$setting['icon_name'] = $set['icon_name'];
$setting['iconLink'] = $set['iconLink'] ?: "";
$setting['iconSmileLink'] = $set['iconSmileLink'];
$setting['is_show_name'] = $set['is_show_name']?:0;
$setting['is_member_enter'] = isset($set['is_member_enter']) ? $set['is_member_enter']: 1;
$setting['is_show_video_progress'] = $set['is_show_video_progress']?1:0;
return $this->successJson("",['set' => $setting]);
}
//获取分类
public function getCategory()
{
$set = \Setting::get('plugin.video-share');
$data = [];
if ($set['is_show_cate'] != 1) {
return $this->successJson("",$data);
}
$is_select = request()->is_select;
if ($set['is_show_hide'] == 1 && $is_select == 1) {
$category = CategoryModel::uniacid()->select("id","name")->orderBy('sort','desc')->get();
} else {
$category = CategoryModel::uniacid()->select("id","name")->where("is_show",1)->orderBy('sort','desc')->get();
}
$category = empty($category) ? [] : $category->toArray();
return $this->successJson("",$category);
}
//关注/取消关注
public function editFollow()
{
$uid = request()->get("member_id");
$type = Request()->get("follow_type");
$member_id = \YunShop::app()->getMemberId();
if ($type == 1) {
//关注
$exist = Follow::uniacid()->where("member_id",$uid)->where("follow_member_id",$member_id)->count();
if ($exist>0) {
return $this->errorJson("已关注");
}
$follow_data = [
"uniacid" => \YunShop::app()->uniacid,
"member_id" => $uid,
"follow_member_id" => $member_id,
"created_at" => time(),
"updated_at" => time()
];
if (Follow::insert($follow_data)) {
return $this->successJson("成功");
}
return $this->errorJson("失败");
} elseif ($type == 2) {
//取消关注
//关注
$follow = Follow::uniacid()->where("member_id",$uid)->where("follow_member_id",$member_id)->first();
if (!$follow) {
return $this->errorJson("数据错误");
}
$follow->deleted_at = time();
if($follow->save()) {
return $this->successJson("成功");
}
return $this->errorJson("失败");
} else {
return $this->errorJson("数据错误");
}
}
//添加观看记录
public function addRecord(){
$uid = \YunShop::app()->getMemberId();
$videoId = request()->video_id;
$result = VideoShareWatchRecord::create(['member_id' => $uid, 'video_id' => $videoId]);
$this->addBrowseFootprintRedis($videoId);
return $this->successJson('成功', $result);
}
protected static function addBrowseFootprintRedis($videoId)
{
if (app('plugins')->isEnabled('browse-footprint')){
$page_type = '/videoDetail';
$fullUrl = yzAppFullUrl('/videoDetail',['vid' => $videoId]);
if (request()->type == 2) {
$page_type = 'packageC/video_goods/VideoDetail/VideoDetail';
$fullUrl = 'packageC/video_goods/VideoDetail/VideoDetail?vid' . $videoId;
}
$temporary_data = [
'member_id' => \YunShop::app()->getMemberId(),//会员id
'page_type' => $page_type,//页面类型
'page_type_id' => $videoId,//页面类型ID
'port_type' => request()->type,//端口类型
'pc' => request()->input('pc') ?: 0,//参数为1 & type=5 为PC端
'ip' => Utils::getClientIp() ?: 0,
'ip_name' => '未知',//TODO 需要引库
'i' => \YunShop::app()->uniacid,
'cookie' => substr(md5(request()->header()['cookie'][0]), 8, 16),
'full-url' => $fullUrl ?: '',//完整URL链接
'mid' => (int)request()->mid ?: 0,//完整URL链接
'created_at' => time()
];
$json = json_encode($temporary_data);
Redis::lpush('plugin-browse_footprint:middleware', $json);
}
}
// 发布 plugin.video-share.frontend.video.sub
public function sub()
{
$uid = \YunShop::app()->getMemberId();
$goodsId = intval(request()->goods_id);
$title = request()->title;
$video = request()->video;
$file_name = request()->file_name;
$cover = request()->cover;
$ingress = request()->ingress;
$category_id = request()->category_id;
$set = \Setting::get('plugin.video-share');
if($set['default_title']) $title = $set['default_title'];
if($set['default_cate']) $category_id = $set['default_cate'];
if (!$title) {
return $this->errorJson('标题参数错误');
}
if (!$video && $set['must_video'] == 1) {
return $this->errorJson('视频参数错误');
}
if (!$cover) {
return $this->errorJson('封面参数错误');
}
if(!isset($set['select_goods']) || $set['select_goods']){
//需要选择商品(todo 未设置信息的时候默认需要选择商品)
if (!$goodsId) {
return $this->errorJson('请选择商品');
}
}else{//已关闭选择商品
$goodsId = 0;
}
if (!$set['is_review']){//判断是否开启审核
$status = 1;
}else{
$status = 0;
}
if ($ingress) {
$check_result = (new MiniFileLimitService())->checkMsg($title);
if ($check_result['errcode'] != 0) {
return $this->errorJson('输入信息含有违法违规内容');
}
}
$data = [
'goods_id' => $goodsId,
'uniacid' => \YunShop::app()->uniacid,
'uid' => $uid,
'title' => $title,
'video' => $video?:'',
'file_name' => $file_name?:'',
'cover' => $cover,
'share_num' => 0,
'like_num' => 0,
'order_price' => 0,
'amount_total' => 0,
'status' => $status,
'category_id'=>empty($category_id) ? 0 : $category_id
];
if (request()->is_crm) {
$data['is_crm'] = 1;
}
$video = VideoShareGoods::create($data);
event(new VideoPublishEvent($video));
return $this->successJson('成功', [
'style_type' => $set['list_style'] == 2 ? '2' : '1' //前端列表样式
]);
}
// 保存视频 暂时不用
public function upload()
{
$file = request()->file('file');
if (!$file) {
return $this->errorJson('请传入正确参数.');
}
if ($file->isValid()) {
// 获取文件相关信息
$originalName = $file->getClientOriginalName(); // 文件原名
$realPath = $file->getRealPath(); //临时文件的绝对路径
$ext = $file->getClientOriginalExtension();
$newOriginalName = md5($originalName . str_random(6)) . '.' . $ext;
\Storage::disk('image')->put($newOriginalName, file_get_contents($realPath));
return $this->successJson('上传成功', [
'img' => \Storage::disk('image')->url($newOriginalName),
]);
}
}
// 查看
public function getVideoGoods()
{
$uid = \YunShop::app()->getMemberId();
$videoGoodsId = intval(request()->video_goods_id);
if (!$videoGoodsId) {
return $this->errorJson('参数错误[video_goods_id=null]');
}
$videoGoods = VideoShareGoods::with([
'member' => function ($member) {
$member->select(['avatar', 'uid', 'nickname']);
},
'goods' => function ($goods) {
$goods->select(['id', 'title', 'price', 'market_price', 'thumb','has_option']);
}
])->where('status', 1)
->find($videoGoodsId);
if (!$videoGoods) {
return $this->errorJson('未找到信息');
}
$businessCard = app('plugins')->isEnabled('business-card');
$videoGoods->member->business_card = 0;
if ($businessCard) {
$cardModel = BusinessCardModel::select()
->where('member_id', $videoGoods->member->uid)
->first();
if ($cardModel) {
$videoGoods->member->business_card = $cardModel->id;
}
}
$videoGoods->goods->thumb = yz_tomedia($videoGoods->goods->thumb);
$videoGoods->cover = yz_tomedia($videoGoods->cover);
$videoGoods->video = yz_tomedia($videoGoods->video);
$videoGoods->member_video_num = count(VideoShareGoods::where('uid', $videoGoods->member->uid)->whereNotNull('video')->get());
$videoGoods->comment_num = Comment::where('video_id',$videoGoodsId)->count();
// 会员点赞 默认可以点赞
$videoGoods->member_like = 1;
$likeLog = LikeLog::select()
->where('uid', $uid)
->where('vid', $videoGoodsId)
->first();
if ($likeLog) {
$videoGoods->member_like = 0;
}
//投放广告视频插件-观看赚/投放广告按钮
$videoGoods->ad_serving_button_status = [];
if (app('plugins')->isEnabled('ad-serving')) {
$videoGoods->ad_serving_button_status = \Yunshop\AdServing\services\PrivilegeValidateService::checkButton(request()->video_goods_id,2);
}
//判断当前会员是否在直播
$is_live = 0;
if (app('plugins')->isEnabled('room')) {
$member_id = \YunShop::app()->getMemberId();
$anchor = \Yunshop\Room\models\Anchor::uniacid()->where("member_id",$member_id)->first();
if ($anchor) {
$is_live = $anchor['status'];
}
}
//判断是否关注
$follow = Follow::uniacid()->where("member_id",$videoGoods->uid)->where("follow_member_id",$uid)->count();
return $this->successJson('成功', [
'video_goods' => $videoGoods,
'is_live' => $is_live,
'is_follow' => ($follow>0) ? 1 : 0
]);
}
// 增加分享次数 plugin.video-share.frontend.video.share
public function share()
{
$videoGoodsId = intval(request()->video_goods_id);
if (!$videoGoodsId) {
return $this->errorJson('参数错误[video_goods_id=null]');
}
$videoGoods = VideoShareGoods::find($videoGoodsId);
if (!$videoGoods) {
return $this->errorJson('未找到信息');
}
$videoGoods->share_num += 1;
$videoGoods->save();
return $this->successJson('分享次数增加成功',$videoGoods->share_num);
}
// 增加点赞次数
public function like()
{
$uid = \YunShop::app()->getMemberId();
$videoGoodsId = intval(request()->video_goods_id);
if (!$videoGoodsId) {
return $this->errorJson('参数错误[video_goods_id=null]');
}
$videoGoods = VideoShareGoods::find($videoGoodsId);
if (!$videoGoods) {
return $this->errorJson('未找到信息');
}
$likeLog = LikeLog::select()
->where('uid', $uid)
->where('vid', $videoGoodsId)
->first();
if ($likeLog) {
$videoGoods->like_num -= 1;
$likeLog->delete();
$msg = '点赞取消成功';
} else {
$videoGoods->like_num += 1;
LikeLog::create([
'uniacid' => \YunShop::app()->uniacid,
'uid' => $uid,
'vid' => $videoGoodsId
]);
$msg = '点赞成功';
}
$videoGoods->save();
return $this->successJson($msg, [
]);
}
/**
* 会员发布的视频列表
*/
public function myVideo()
{
$status = request()->status;
$uid = request()->v_uid ?: \Yunshop::app()->getMemberId();
// $set = \Setting::get('plugin.video-share');
$videos = VideoShareGoods::myVideo($uid)->where(['status' => $status])
->orderBy('id', 'desc')
->paginate(20);
foreach ($videos as &$item){
$item['goods']['thumb'] = yz_tomedia($item['goods']['thumb']);
$item['cover'] = yz_tomedia($item['cover']);
$item['video'] = yz_tomedia($item['video']);
// 会员点赞 默认可以点赞
$item->member_like = 1;
$likeLog = LikeLog::select()
->where('uid', $uid)
->where('vid', $item->id)
->first();
if ($likeLog) {
$item->member_like = 0;
}
//视频数量
$item->member_video_num = count(VideoShareGoods::where('uid', $uid)->whereNotNull('video')->get());
//评论数量
$item->comment_num = Comment::uniacid()->where(['video_id' => $item->id, 'comment_id' => 0])->count();
}
$release = VideoShareGoods::myVideo($uid)->where('status',1)->count();//发布总数
$review = VideoShareGoods::myVideo($uid)->where('status',0)->count();//审核总数
$member = Member::uniacid()->select('uid', 'avatar', 'nickname')->where('uid',$uid)->first();
return $this->successJson('成功', [
'video' => $videos,
'member' => $member,
'release' => $release,
'review' => $review,
'is_open' => \Setting::get('plugin.video-share')['is_review'] ?: 0
]);
}
public function del()
{
$id = request()->id;
$member_id = \Yunshop::app()->getMemberId();
//进行文件删除
$videoGoods = VideoShareGoods::where('id', $id)->where('uid', $member_id)->first();
if (empty($videoGoods)) {
return $this->errorJson('视频不存在或已删除');
}
Storage::disk('audios')->delete($videoGoods->file_name);
$result = VideoShareGoods::where('id',$id)->delete();
if ($result) {
return $this->successJson('删除成功');
} else {
return $this->errorJson('数据异常,删除失败');
}
}
public function watchVideo()
{
$video_id = request()->video_id;
$video = VideoShareGoods::uniacid()->where('id', $video_id)->first();
//触发观看视频事件
//event((new VideoWatchEvent($video_id, \Yunshop::app()->getMemberId())));
if (!$video || !app('plugins')->isEnabled('video-share-points')) {
return $this->successJson('ok', ['is_show' => false]);
}
//观看奖励
$res = (new \Yunshop\VideoSharePoints\common\services\VideoWatchService)->handle(\Yunshop::app()->getMemberId(), $video_id);
if ($res['judge'] && $res['points'] > 0) {
return $this->successJson('ok', ['is_show' => true, 'points' => $res['points'], 'point_name' => $res['name'], 'days' => $res['days'] ?: 0]);
} else {
return $this->successJson('ok', ['is_show' => false]);
}
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace Yunshop\VideoShare\widgets;
use app\common\components\Widget;
use app\common\facades\Setting;
class WithdrawWidget extends Widget
{
public function run()
{
$set = Setting::get('withdraw.video_share_withdraw', ['roll_out_limit' => '', 'poundage_rate' => '']);
return view('Yunshop\VideoShare::withdraw.index', [
'set' => $set,
])->render();
}
}

View File

@ -0,0 +1,190 @@
@extends('layouts.base')
@section('title', '分红记录')
@section('content')
<style>
.record #app .record-title{padding:15px 0;padding-bottom:10px;font-size:16px;line-height:30px;border-bottom:solid 1px #eee;color:#333;margin-bottom:25px;}
.amount{margin-bottom:15px;}
</style>
<div class="record">
<div id="app">
<div class="record-title">
<b>分红记录</b>
</div>
<template>
<el-form :inline="true" :model="search_form" ref="search_form">
<el-row>
<el-col :span="24">
<el-form-item label="视频ID">
<el-input v-model="search_form.vid" placeholder="请输入视频ID"></el-input>
</el-form-item>
<el-form-item label="会员ID">
<el-input v-model="search_form.uid" placeholder="请输入会员ID"></el-input>
</el-form-item>
<el-form-item label="会员昵称/姓名/手机号">
<el-input v-model="search_form.member" placeholder="请输入会员昵称/姓名/手机号"></el-input>
</el-form-item>
<el-form-item label="发现标题">
<el-input v-model="search_form.vtitle" placeholder="请输入发现标题"></el-input>
</el-form-item>
<el-form-item label="商品ID">
<el-input v-model="search_form.vgoods_id" placeholder="请输入商品ID"></el-input>
</el-form-item>
<el-form-item label="时间范围">
<el-date-picker v-model="search_form.time" type="datetimerange" range-separator="" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item>
<template>
<el-select v-model="seleceTime" placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</el-form-item>
<el-form-item style="text-align:right;">
<a href="#">
<el-button type="success" icon="el-icon-search" @click="search()">搜索</el-button>
</a>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="amount"><span>累计订单金额:[[statistic.order_price]],</span><span>累计奖励金额:[[statistic.amount]]</span></div>
<div class="rest"><span>已结算累计订单金额:[[statistic.finish_order_price]],</span><span>已结算累计奖励金额:[[statistic.wait_amount]]</span></div>
<template>
<!-- 表格start -->
<el-table :data="list" style="width: 100%" v-loading="search_loading">
<el-table-column prop="id" label="时间" align="center">
<template slot-scope="scope">
<div>[[scope.row.created_at]]</div>
</template>
</el-table-column>
<el-table-column prop="vid" label="视频ID" align="center"></el-table-column>
<el-table-column prop="member" label="会员" align="center">
<template slot-scope="scope" v-if="scope.row.member">
<img :src="scope.row.member.avatar_image" style="width:30px;height:30px;padding:1px;border:1px solid #ccc;">
<div>[[scope.row.member.nickname]]</div>
</template>
</el-table-column>
<el-table-column prop="title" label="发现标题" align="center">
<template slot-scope="scope">
<span>[[scope.row.video.title]]</span>
</template>
</el-table-column>
<el-table-column prop="order" label="订单号" prop="number" align="center">
<template slot-scope="scope">
<span>[[scope.row.order.order_sn]]</span>
</template>
</el-table-column>
<el-table-column prop="order_price" label="订单金额(元)" prop="number" align="center"></el-table-column>
<el-table-column prop="ratio" label="奖励比例%" prop="number" align="center"></el-table-column>
<el-table-column prop="amount" label="奖励金额(元)" prop="number" align="center"></el-table-column>
<el-table-column prop="status_name" label="状态" prop="number" align="center"></el-table-column>
</el-table>
<el-row>
<el-col :span="24" align="right" migra style="padding:15px 5% 15px 0" v-loading="loading">
<el-pagination background layout="prev, pager, next" @current-change="currentChange" :total="page_total"
:page-size="page_size" :current-page="current_page"></el-pagination>
</el-col>
</el-row>
<!-- 表格end -->
</template>
</template>
</div>
</div>
<script>
var vm = new Vue({
el:"#app",
delimiters: ['[[', ']]'],
data() {
let record = {!! $list?:'{}' !!}
let record_statistic = {!! $statistic?:'{}' !!}
return{
statistic:record_statistic,
list:record.data,
loading:false,
page_total:record.total,
page_size:record.per_page,
current_page:record.current_page,
search_form:{
is_time:''
},
real_search_form:{},
search_loading:false,
seleceTime:'',
options:[
{
value:1,
label:'搜索发布时间'
},
{
value:0,
label:'不搜索发布时间'
}
],
}
},
mounted: function () {
},
methods: {
currentChange(val) {
this.loading = true;
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.bonus.getListBySearch') !!}',{page:val,search:this.real_search_form}).then(function (response){
let data = response.data.data.list;
this.page_total = data.total;
this.list = data.data;
this.page_size = data.per_page;
this.current_page = data.current_page;
this.loading = false;
},function (response) {
console.log(response);
this.loading = false;
}
);
},
search() {
this.search_form.start_time='';
this.search_form.end_time='';
if(this.seleceTime===0){
this.search_form.is_time=0;
this.search_loading = true;
}
else{
this.search_loading = true;
this.search_form.is_time=1;
if(this.search_form.time){
this.search_form.is_time=1;
this.search_form.start_time = Math.round(this.search_form.time[0]/1000).valueOf();
this.search_form.end_time = Math.round(this.search_form.time[1]/1000).valueOf();
}
}
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.bonus.getListBySearch') !!}',{search:this.search_form}
).then(function (response) {
if (response.data.result){
let data = response.data.data.list;
this.page_total = data.total;
this.list = data.data;
this.page_size = data.per_page;
this.current_page = data.current_page;
this.loading = false;
this.real_search_form=Object.assign({},this.search_form);
}
else {
this.$message({message: response.data.msg,type: 'error'});
}
this.search_loading = false;
},function (response) {
this.search_loading = false;
this.$message({message: response.data.msg,type: 'error'});
}
);
},
},
});
</script>
@endsection

View File

@ -0,0 +1,122 @@
@extends('layouts.base')
@section('content')
<style>
.panel{
margin-bottom:10px!important;
padding-left: 20px;
border-radius: 10px;
}
.panel .active a {
background-color: #29ba9c!important;
border-radius: 18px!important;
color:#fff;
}
.panel a{
border:none!important;
background-color:#fff!important;
}
.content{
background: #eff3f6;
padding: 10px!important;
}
.con{
padding-bottom:20px;
position:relative;
min-height:100vh;
background-color:#fff;
border-radius: 8px;
}
.con .setting .block{
padding:10px;
background-color:#fff;
border-radius: 8px;
}
.con .setting .block .title{
display:flex;
align-items:center;
margin-bottom:15px;
}
.confirm-btn{
width: calc(100% - 266px);
position:fixed;
bottom:0;
right:0;
margin-right:10px;
line-height:63px;
background-color: #ffffff;
box-shadow: 0px 8px 23px 1px
rgba(51, 51, 51, 0.3);
background-color:#fff;
text-align:center;
}
b{
font-size:14px;
}
</style>
<div id='re_content' >
<div class="con">
<div class="setting">
<div class="block">
<div class="title"><span style="width: 4px;height: 18px;background-color: #29ba9c;margin-right:15px;display:inline-block;"></span><b>分类编辑</b></div>
<el-form ref="form" :model="form" label-width="15%">
<el-form-item label="排序">
<el-input v-model="form.sort" style="width:70%;"></el-input>
</el-form-item>
<el-form-item label="分类名称">
<el-input v-model="form.name" style="width:70%;"></el-input>
</el-form-item>
<el-form-item label="是否显示">
<template>
<el-switch
v-model="form.is_show"
:active-value="1"
:inactive-value="0"
>
</el-switch>
</template>
</el-form-item>
</div>
</div>
<div class="confirm-btn">
<el-button type="primary" @click="submit">提交</el-button>
</div>
</div>
</div>
<script>
var vm = new Vue({
el: "#re_content",
delimiters: ['[[', ']]'],
data() {
let cate={!!json_encode($cate?:'{}') !!}
return {
cate_id:cate&&cate.id?cate.id:'',
form:{
name:cate&&cate.name?cate.name:'',
sort:cate&&cate.sort?cate.sort:'',
is_show:cate&&cate.is_show?cate.is_show:0,
},
}
},
mounted () {
},
methods: {
submit() {
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.category.edit') !!}',{'cate_data':this.form,'cate_id':this.cate_id}).then(function (response){
if (response.data.result) {
this.$message({message: response.data.msg,type: 'success'});
window.location.href='{!! yzWebFullUrl('plugin.video-share.admin.category.index') !!}';
}else {
this.$message({message: response.data.msg,type: 'error'});
}
},function (response) {
this.$message({message: response.data.msg,type: 'error'});
})
},
},
});
</script>
@endsection

View File

@ -0,0 +1,181 @@
@extends('layouts.base')
@section('title', '发现管理')
@section('content')
<style>
.find-manage #app .manage-title{padding:15px 0;padding-bottom:10px;font-size:16px;line-height:30px;border-bottom:solid 1px #eee;color:#333;margin-bottom:25px;}
.el-switch.is-checked .el-switch__core::after {left: 100%;margin-left: -17px;}
.el-switch__core::after {content: "";position: absolute;top: 1px;left: 1px;border-radius: 100%;transition: all .3s;width: 16px;height: 16px;background-color: #fff;}
</style>
<div class="find-manage">
<div id="app">
<div class="manage-title">
<b>发现管理</b>
</div>
<template>
<el-form :inline="true" :model="search_form" ref="search_form">
<el-row>
<el-col :span="24">
<el-form-item label="视频分类">
<el-input v-model="search_form.keyword" placeholder="请输入分类ID/名称"></el-input>
</el-form-item>
<el-form-item style="text-align:right;">
<a href="#">
<el-button type="success" icon="el-icon-search" @click="search()">搜索</el-button>
</a>
<a href="{{ yzWebFullUrl('plugin.video-share.admin.category.edit') }}"><el-button type="primary" style="margin-left:30px;" size="mini">添加分类</el-button></a>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template>
<!-- 表格start -->
<el-table :data="list" style="width: 100%" v-loading="search_loading">
<el-table-column prop="id" label="ID" align="center"></el-table-column>
<el-table-column prop="sort" label="排序" align="center"></el-table-column>
<el-table-column prop="name" label="分类名称" align="center"></el-table-column>
<el-table-column prop="is_show" label="是否显示" align="center">
<template slot-scope="scope">
<el-switch
v-model="scope.row.is_show"
:active-value="1" :inactive-value="2"
active-color="#13ce66"
@change="Switch(scope,list)">
</el-switch>
</template>
</el-table-column>
<el-table-column prop="amount_total" label="视频数量" align="center"></el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope" >
<a :href="'{{ yzWebFullUrl('plugin.video-share.admin.videoGoods.index', array("search[category_id]" => '')) }}'+[[scope.row.id]]" title="查看视频" style="color:#999"><i class="iconfont icon-fontclass-fenlei1" style="font-size:16px;margin-right:35px;"></i></a>
<a :href="'{{ yzWebFullUrl('plugin.video-share.admin.category.edit', array('cate_id' => '')) }}'+[[scope.row.id]]" title="编辑" style="color:#999"><i class="iconfont icon-ht_operation_edit" style="font-size:16px;margin-right:35px;"></i></a>
<a title="删除" style="color:#999;margin-left: -10px;"><i class="iconfont icon-ht_operation_delete" style="font-size:16px;" @click="del(scope, list)"></i></a>
</template>
</el-table-column>
<el-row>
<el-col :span="24" align="right" migra style="padding:15px 5% 15px 0" v-loading="loading">
<el-pagination background layout="prev, pager, next" @current-change="currentChange" :total="page_total"
:page-size="page_size" :current-page="current_page"></el-pagination>
</el-col>
</el-row>
</el-table>
</template>
</template>
<!-- 分页 -->
<div class="vue-page">
<el-row>
<el-col align="right">
<el-pagination layout="prev, pager, next,jumper" @current-change="currentChange" :total="page_total" :page-size="page_size" :current-page="current_page" background></el-pagination>
</el-col>
</el-row>
</div>
</div>
<script>
var vm = new Vue({
el:"#app",
delimiters: ['[[', ']]'],
data() {
let List = {!! $list?:'{}' !!}
console.log(List);
return{
is_open:false,
list:List.data,
loading:false,
page_total:List.total,
page_size:List.per_page,
current_page:List.current_page,
search_form:{
},
real_search_form:{},
search_loading:false,
videolist:'',
}
},
mounted: function () {
},
methods: {
currentChange(val) {
this.loading = true;
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.category.search') !!}',{page:val,search:this.real_search_form}).then(function (response){
let data = response.data.data.list;
this.page_total = data.total;
this.list = data.data;
this.page_size = data.per_page;
this.current_page = data.current_page;
this.loading = false;
},function (response) {
console.log(response);
this.loading = false;
}
);
},
search() {
this.search_loading = true;
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.category.search') !!}',{search:this.search_form}
).then(function (response) {
if (response.data.result){
let data = response.data.data.list;
console.log(data);
this.page_total = data.total;
this.list = data.data;
this.page_size = data.per_page;
this.current_page = data.current_page;
this.loading = false;
this.real_search_form=Object.assign({},this.search_form);
}
else {
this.$message({message: response.data.msg,type: 'error'});
}
this.search_loading = false;
},function (response) {
this.search_loading = false;
this.$message({message: response.data.msg,type: 'error'});
}
);
},
del(scope, rows){
if(confirm("确认删除?")) {
rows.splice(scope.$index, 1);
let json={
id:scope.row.id
}
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.category.del') !!}',json).then(function (response){
if (response.data.result) {
this.$message.success("删除成功");
} else {
this.$message({message: response.data.msg,type: 'error'});
}
},function (response) {
console.log(response);
this.loading = false;
}
);
}
},
Switch(scope, rows){
if(confirm("确认修改?")) {
// rows.splice(scope.$index, 1);
let json={
id:scope.row.id
}
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.category.changeStatus') !!}',json).then(function (response){
if (response.data.result) {
this.$message.success("编辑成功");
} else {
this.$message({message: response.data.msg,type: 'error'});
}
},function (response) {
console.log(response);
this.loading = false;
}
);
}
},
},
});
</script>
@endsection

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,141 @@
@extends('layouts.base')
@section('title', '评论管理')
@section('content')
<link rel="stylesheet" href="{{resource_get('plugins/video-share/assets/css/comment.css?time='.time())}}">
<div class="find-manage">
<div id="app">
<div class="commit-title">
<b>评论管理 ([[total]])</b>
</div>
<el-form :inline="true">
<el-form-item label="">
<el-input placeholder="请输入视频标题" v-model="form.video_title"></el-input>
</el-form-item>
<el-form-item label="">
<el-input placeholder="评论会员ID" v-model="form.member_id"></el-input>
</el-form-item>
<el-form-item label="">
<el-input placeholder="评论会员昵称/姓名、手机号" v-model="form.member_msg"></el-input>
</el-form-item>
<el-form-item label="">
<el-date-picker value-format="timestamp"  type="datetimerange" v-model="date" range-separator="" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item label="">
<el-button type="primary" class="el-icon-search" @click="search1(1)">搜索</el-button>
</el-form-item>
<el-table :data="listData" :header-cell-style="{ 'text-align': 'center' }" :cell-style="{ 'text-align': 'center' }">
<el-table-column prop="created_at" label="评论时间"></el-table-column>
<el-table-column label="发现标题">
<template slot-scope="scope">
<span>[[scope.row.video?.video_title]]</span>
</template>
</el-table-column>
<el-table-column label="发现视频">
<template slot-scope="scope">
<img :src="scope.row.video?.cover" class="video-style" @click="checkVideo(scope.row)">
</template>
</el-table-column>
<el-table-column label="评论者">
<template slot-scope="scope">
<img :src="scope.row.head_img_url" alt="" class="img-style" v-if="scope.row.head_img_url">
<div>[[scope.row.nick_name]]</div>
</template>
</el-table-column>
<el-table-column prop="content" label="评论内容"></el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<i class="el-icon-delete-solid" @click="delCommit(scope.row.id)"></i>
</template>
</el-table-column>
</el-table>
</el-form>
<!-- 分页 -->
<div class="vue-page">
<el-row>
<el-col align="right">
<el-pagination layout="prev, pager, next,jumper" @current-change="search1" :total="total" :page-size="per_page" :current-page="current_page" background></el-pagination>
</el-col>
</el-row>
</div>
<el-dialog title="视频播放" :visible.sync="visibleVideo" >
<div style="text-align: center">
<video :src="video_url" controls="controls"></video>
</div>
</el-dialog>
</div>
<script>
var vm = new Vue({
el: "#app",
delimiters: ['[[', ']]'],
data() {
return {
form: {
video_title: "",
member_id: "",
member_msg: ""
},
date: [],
listData:[],
visibleVideo:false,
video_url:'',
current_page: 1,
total: 1,
per_page: 1,
}
},
mounted() {
this.getData(1);
},
methods: {
search1(page) {
this.getData(page);
},
async getData(page) {
let time = null;
if(this.date !== null && this.date.length) {
time = {
start: this.date[0] / 1000 ,
end: this.date[1] / 1000
}
}
let res = await this.$http.post("{!! yzWebFullUrl('plugin.video-share.admin.video-comments.get-comments-category-list') !!}", {
page,
search:{
...this.form,
time
}
})
if(res.data.result){
// console.log(res.data,'121213');
this.listData = res.data.data.data;
this.current_page = res.data.data.current_page;
this.total = res.data.data.total;
this.per_page = res.data.data.per_page;
}else{
this.$message.error(res.data.msg);
}
},
// 查看视频
checkVideo(row) {
this.video_url = row.video.video_url;
this.visibleVideo = true;
},
// 删除评论
delCommit(id) {
this.$confirm('是否删除该评论?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(async () => {
let res = await this.$http.post("{!! yzWebFullUrl('plugin.video-share.admin.video-comments.del') !!}", {id})
if(res.data.result){
this.getData(1);
this.$message.success(res.data.msg);
}else{
this.$message.error(res.data.msg);
}
}).catch(() => {});
}
}
})
</script>
@endsection

View File

@ -0,0 +1,145 @@
@extends('layouts.base')
@section('title', '查看评论')
@section('content')
<link rel="stylesheet" href="{{resource_get('plugins/video-share/assets/css/comment.css?time='.time())}}">
<div class="find-manage">
<div id="app">
<div class="commit-title">
<b>查看评论 ([[num]])</b>
<b class="space-li" @click="expendAllCommit">展开子评论</b>
<b class="space-li" @click="stowAllReplay">收起子评论</b>
<el-button plain size="small" @click="goBack">返回列表</el-button>
</div>
<div class="commit-box">
<div class="commit-detail" v-for="(item,index) in commit" :key="index">
<div class="parent-text">
<img :src="item.head_img_url" >
<div class="right-text">
<b class="member-detail">
<span class="username">[[item.nick_name]]</span>
<i class="el-icon-delete" @click="delCommit(item.id)"></i>
</b>
<div class="time color-bg">[[item.created_at]]</div>
<div class="bottom-text color-bg parent-content">[[item.content]]</div>
<div class="stow color-bg" v-if="item.children_comment.length && !item.moreReply" @click="expendMoreReplay(item.id)">
<span>展开更多回复</span>
<i class="el-icon-arrow-down"></i>
</div>
</div>
</div>
<div class="son-text" v-for="(sonItem , sonIndex) in item.children_comment" :key="sonIndex" v-if="item.moreReply">
<img :src="sonItem.head_img_url" >
<div class="right-text">
<b class="member-detail">
<span class="username">[[sonItem.nick_name]]</span>
<i class="el-icon-delete" @click="delCommit(sonItem.id)"></i>
</b>
<div class="time color-bg">[[sonItem.created_at]]</div>
<div class="bottom-text color-bg"><span v-if="sonItem.reply_name !== null">回复 <b class="replay-name">[[sonItem.reply_name]]</b></span> &nbsp;<span>[[sonItem.content]]</span></div>
<div class="stow color-bg" v-if="sonIndex == item.children_comment.length - 1" @click="stowReplay(item.id)">
<span>收起</span>
<i class="el-icon-arrow-up"></i>
</div>
</div>
</div>
</div>
</div>
<!-- 分页 -->
<div class="vue-page">
<el-row>
<el-col align="right">
<el-pagination layout="prev, pager, next,jumper" @current-change="search1" :total="total" :page-size="per_page" :current-page="current_page" background></el-pagination>
</el-col>
</el-row>
</div>
</div>
<script>
let id = "{{ request()-> id }}"
var vm = new Vue({
el: "#app",
delimiters: ['[[', ']]'],
data() {
return {
commit: [],
num:0,
current_page: 1,
total: 1,
per_page: 1,
}
},
mounted() {
this.getData(1);
},
methods: {
async getData(page) {
let res = await this.$http.post("{!! yzWebFullUrl('plugin.video-share.admin.video-comments.get-display-comments-list') !!}", {
page,
id
})
if(res.data.result){
// console.log(res.data,'121213');
this.num = res.data.data.num;
this.commit = res.data.data.commentsList.data;
this.current_page = res.data.data.commentsList.current_page;
this.total = res.data.data.commentsList.total;
this.per_page = res.data.data.commentsList.per_page;
}else{
this.$message.error(res.data.msg);
}
},
search1(page) {
this.getData(page);
},
// 展开更多回复
expendMoreReplay(id) {
for(let item of this.commit) {
if(item.id == id) {
this.$set(item,'moreReply',true);
break;
}
}
},
// 收起评论
stowReplay(id) {
for(let item of this.commit) {
if(item.id == id) {
this.$set(item,'moreReply',false);
break;
}
}
},
// 展开子评论
expendAllCommit() {
for(let item of this.commit) {
this.$set(item,'moreReply',true);
}
},
// 收起子评论
stowAllReplay() {
for(let item of this.commit) {
this.$set(item,'moreReply',false);
}
},
// 返回列表
goBack() {
window.history.back();
},
// 删除评论
delCommit(id) {
this.$confirm('是否删除该评论?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(async () => {
let res = await this.$http.post("{!! yzWebFullUrl('plugin.video-share.admin.video-comments.del') !!}", {id})
if(res.data.result){
this.getData(1);
this.$message.success(res.data.msg);
}else{
this.$message.error(res.data.msg);
}
}).catch(() => {});
}
}
})
</script>
@endsection

View File

@ -0,0 +1,214 @@
<template id="videoCard">
<el-dialog title=" " :visible.sync="dialogVisible" width="600px" :before-close="handleClose" :show-close="false">
<div class="top-title">更换视频</div>
<div class="detail-pane">
<div class="detail-top">
<span class="video-source">视频源:</span>
<el-radio-group v-model="radio_type">
<el-radio :label="1">上传</el-radio>
<el-radio :label="2">视频地址</el-radio>
</el-radio-group>
</div>
<div class="img-box">
<div v-if="radio_type == 1">
<div class="upload-box upload-boxed" v-if="!form.video_file" @click="upload('3')">
<i class="el-icon-plus" style="font-size:32px"></i>
<div class="upload-boxed-text">点击重新上传视频</div>
</div>
<div class="upload-boxed" v-if="form.video_file">
<video :src="form.video_file" alt="" controls="controls" class="upload-sty"></video>
<div class="upload-boxed-text" @click="upload('3')">点击重新上传视频</div>
</div>
</div>
<div class="video-upload-sty" v-if="radio_type == 2">
<textarea class="video-upload-textarea" cols="40" rows="7" v-model="form.video_url" placeholder="以https://开头, .MP4结尾的视频地址"></textarea>
</div>
<div>
<div class="upload-box upload-boxed" v-if="!form.img_url" @click="upload('1')">
<i class="el-icon-plus" style="font-size:32px"></i>
<div class="upload-boxed-text">点击重新上传封面</div>
</div>
<div class="upload-boxed" v-if="form.img_url" @click="upload('1')">
<img :src="form.img_url" alt="" class="upload-sty">
<div class="upload-boxed-text">点击重新上传封面</div>
</div>
</div>
</div>
</div>
<div class="bottom-pane">
<span class="save-sty" @click="save">保存</span>
<span class="cancal-sty" @click="handleClose">取消</span>
</div>
<upload-multimedia-img :upload-show="showSelectMaterialPopup" :type="type" sel-num="one" select="open" @replace="showSelectMaterialPopup = !showSelectMaterialPopup" @sure="selectedMaterial"></upload-multimedia-img>
</el-dialog>
</template>
<link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}" />
<link rel="stylesheet" href="{{static_url('css/public-number.css')}}">
<script>
Vue.component('videoCard', {
template: '#videoCard',
delimiters: ['[[', ']]'],
props: {
dialogVisible: {
type: Boolean,
default: false
},
video_row: {
type: null,
default: {}
}
},
data() {
return {
radio_type: 1,
form: {
video_file: "",
img_url: "",
video_url:""
},
showSelectMaterialPopup: false,
type: '',
}
},
mounted() {
this.form.img_url = this.video_row.cover;
this.form.video_file = this.video_row.video_src;
},
methods: {
handleClose() {
this.$emit("update:dialogVisible", false);
this.form.video_file = "";
this.form.img_url = "";
this.form.video_url = "";
},
// 获取图片信息
selectedMaterial(name, image, imageUrl) {
if (this.type == '1') {
this.form.img_url = imageUrl[0].url;
} else if (this.type == '3') {
this.form.video_file = imageUrl[0].url;
}
},
// 上传图片
upload(type) {
this.type = type;
this.showSelectMaterialPopup = true;
},
// 保存
save() {
let form = null;
if(this.radio_type == 1) {
form = {
id: this.video_row.id,
video_file: this.form.video_file,
cover_file: this.form.img_url,
video_url: ""
}
}else if(this.radio_type == 2) {
form = {
id: this.video_row.id,
video_url: this.form.video_url,
cover_file: this.form.img_url,
video_file: ""
}
}
this.$http.post('{!! yzWebFullUrl("plugin.video-share.admin.video-goods.upload-audio") !!}', {...form,type:this.radio_type}).then(({data}) =>{
if(data.result) {
this.$message.success(data.msg);
this.$emit("update:dialogVisible", false);
this.$parent.search();
}else {
this.$message.error(data.msg);
}
}, (response) => {
console.log(response);
});
}
}
})
</script>
<style>
.v-modal {
z-index: 1000 !important;
}
.el-dialog__header {
padding: 0 !important;
}
.top-title {
font-weight: 600;
}
.detail-pane {
margin: 25px;
}
.detail-pane .detail-top {}
.detail-pane .detail-top .video-source {
font-weight: 600;
margin-right: 10px;
}
.bottom-pane {
display: flex;
justify-content: center;
margin: 30px 0;
}
.bottom-pane .save-sty {
background: #59b89d;
color: white;
font-size: 12px;
width: 70px;
height: 28px;
/* text-align: center; */
line-height: 1;
border-radius: 5px;
align-items: center;
display: flex;
justify-content: center;
margin: 0 20px;
cursor: pointer;
}
.bottom-pane .cancal-sty {
background: #a4adb3;
color: white;
font-size: 12px;
width: 70px;
height: 28px;
line-height: 1;
border-radius: 5px;
align-items: center;
display: flex;
justify-content: center;
margin: 0 20px;
cursor: pointer;
}
.img-box {
display: flex;
justify-content: space-between;
margin: 20px 10px;
}
.video-upload-textarea {
resize: none;
border-color: #c5c5c5;
border-radius: 5px;
}
.upload-sty {
width: 150px;
height: 118px;
border-radius: 5px;
cursor: pointer;
object-fit: fill;
}
.upload-boxed-text {
cursor: pointer;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
@extends('layouts.base')
@section('title', '发现管理')
@section('content')
<video src="{{$path}}" controls="controls" id="video">
</video>
<div id="imgbox"></div>
<script type="text/javascript">
(function(){
var video, output;
var scale = 0.8;
var init = function() {
imgbox = document.getElementById("imgbox");
video = document.getElementById("video");
video.addEventListener('loadeddata',captureImage);
};
var dataURItoBlob = function(dataURI) {
// 图片转成Buffer---------------------------------
var byteString = atob(dataURI.split(",")[1]);
var mimeString = dataURI
.split(",")[0]
.split(":")[1]
.split(";")[0];
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ab], { type: mimeString });
}
var captureImage = function() {
var canvas = document.createElement("canvas");//创建一个canvas
canvas.width = video.videoWidth * scale;//设置canvas的宽度为视频的宽度
canvas.height = video.videoHeight * scale;//设置canvas的高度为视频的高度
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);//绘制图像
var img = document.createElement("img");//创建img
img.src = canvas.toDataURL("image/png");//将绘制的图像用img显示出来
let coverUrl = dataURItoBlob(img.src);
console.log(coverUrl);
sub(coverUrl);
imgbox.appendChild(img);//将img添加到imgbox里
};
init();
var sub = function (coverUrl) {
let fd = new FormData();
fd.append("file", coverUrl);
$.post("{!! yzWebUrl('plugin.video-share.frontend.upload.upload') !!}", {
img: fd
}, function (json) {
});
}
})();
</script>
@endsection

View File

@ -0,0 +1,601 @@
@extends('layouts.base')
@section('title', '发现管理')
@section('content')
<style>
.find-manage #app .manage-title{padding:15px 0;padding-bottom:10px;font-size:16px;line-height:30px;border-bottom:solid 1px #eee;color:#333;margin-bottom:25px;}
.el-switch.is-checked .el-switch__core::after {left: 100%;margin-left: -17px;}
.el-switch__core::after {content: "";position: absolute;top: 1px;left: 1px;border-radius: 100%;transition: all .3s;width: 16px;height: 16px;background-color: #fff;}
.find-manage #app .el-dialog__body{position:initial;}
#app {
margin-left: 20px;
}
.replace-sty-box {
display: flex;
justify-content: center;
cursor: pointer;
margin-top: 5px;
}
.replace-sty {
display: flex;
justify-content: center;
background: #29BA9C;
width: 60px;
color: white;
border-radius: 5px;
font-size: 12px;
line-height: 20px;
}
.space-sty {
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}
.find-manage #app .video-sty .el-dialog__body{
padding: 0;
}
.video-sty .el-dialog {
background: rgba(0, 0, 0, 0);
box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}
.el-icon-close:before{
font-size: 50px;
color: #fff;
}
</style>
<div class="find-manage">
<div id="app">
<div class="manage-title">
<b>发现管理</b>
</div>
<template>
<el-form :inline="true" :model="search_form" ref="search_form">
<el-row>
<el-col :span="24">
<el-form-item label="视频ID">
<el-input v-model="search_form.id" placeholder="请输入视频ID"></el-input>
</el-form-item>
<el-form-item label="会员ID">
<el-input v-model="search_form.uid" placeholder="请输入会员ID"></el-input>
</el-form-item>
<el-form-item label="会员昵称/姓名/手机号">
<el-input v-model="search_form.member" placeholder="请输入会员昵称/姓名/手机号"></el-input>
</el-form-item>
<el-form-item label="发现标题">
<el-input v-model="search_form.title" placeholder="请输入发现标题"></el-input>
</el-form-item>
<el-form-item label="商品ID">
<el-input v-model="search_form.goods_id" placeholder="请输入商品ID"></el-input>
</el-form-item>
<el-form-item label="时间范围">
<el-date-picker v-model="search_form.time" type="datetimerange" range-separator="" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item>
<el-form-item>
<template>
<el-select v-model="seleceTime" placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</template>
</el-form-item>
<el-form-item>
<template>
<el-select v-model="search_form.category_id" placeholder="请选择">
<el-option
v-for="item in categorys"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template>
</el-form-item>
<el-form-item style="text-align:right;">
<a href="#">
<el-button type="success" icon="el-icon-search" @click="search()">搜索</el-button>
</a>
<a href="#">
<!-- <el-button type="default" @click="outExcel()">导出EXCEL</el-button> -->
</a>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template>
<!-- 表格start -->
<el-table :data="list" style="width: 100%" v-loading="search_loading">
<el-table-column prop="id" label="视频ID" align="center"></el-table-column>
<el-table-column
align="center"
label="会员">
<template slot-scope="scope">
<template v-if="scope.row.member">
<img :src="scope.row.member.avatar_image" style="width:30px;height:30px;padding:1px;border:1px solid #ccc;">
<div>[[scope.row.member.nickname]]</div>
</template>
<template v-else-if="!scope.row.member">
会员已被删除
</template>
</template>
</el-table-column>
<el-table-column prop="title" label="发现标题" align="center">
<template slot-scope="scope">
<el-popover class="item" placement="top" effect="light">
<div style="text-align:center;">
<div style="text-align:left;margin-bottom:10px;font-weight:900">修改视频标题</div>
<el-input v-model="change_title" style="width:400px" size="small"></el-input>
<el-button size="small" @click="titleChange(scope)">确定</el-button>
</div>
<a slot="reference">
<i class="el-icon-edit edit-i" title="点击编辑" @click="editTitle(scope.$index,'title')"></i>
</a>
</el-popover>
[[scope.row.title]]
</template>
</el-table-column>
<el-table-column prop="cover" label="发现视频" align="center">
<template slot-scope="scope">
<img :src="scope.row.cover" @click="video(scope.row.id)" style="width:60px;height:60px;padding:1px;border:1px solid #ccc;margin-bottom:5px">
<div class="replace-sty-box">
<span class="replace-sty" @click="replaceVideo(scope.row)">更换</span>
</div>
</template>
</el-table-column>
<el-table-column label="视频分类" align="center">
<template slot-scope="scope" >
<el-select v-model="scope.row.category_id" placeholder="请选择" @change="changeCate(scope.row.category_id,scope.row.id)">
<el-option
v-for="item in categorys"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column
align="center"
label="关联商品">
<template slot-scope="scope">
<template v-if="scope.row.goods">
<div class="space-sty" :title="scope.row.goods.title">[[scope.row.goods.title]]</div>
</template>
<template v-else-if="!scope.row.goods && !scope.row.goods_id">
未关联商品
</template>
<template v-else-if="!scope.row.goods && scope.row.goods_id">
商品已被删除
</template>
<div>
<el-button v-if="scope.row.mid_ground_video_id==0" @click="goodsShow(scope.row.id)">更换</el-button>
</div>
</template>
</el-table-column>
<el-table-column label="分享次数/点赞次数/评论数量" align="center">
<template slot-scope="scope">
<span>[[scope.row.share_num]]</span>
<span>/</span>
<span>[[scope.row.like_num]]</span>
<span>/</span>
<span>[[scope.row.comment_sum]]</span>
</template>
</el-table-column>
<el-table-column prop="order_price" label="转化订单金额(元)" align="center"></el-table-column>
<el-table-column prop="amount_total" label="奖励金额(元)" align="center"></el-table-column>
<el-table-column label="" align="center" width="110px">
<template slot-scope="scope">
<a :href="'{{ yzWebFullUrl('plugin.video-share.admin.bonus.index', array('search[vid]' => '',)) }}'+[[scope.row.id]]">
<el-button size="mini">分红记录</el-button>
</a>
</template>
</el-table-column>
<el-table-column label="显示" prop="number" align="center">
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
:active-value="1" :inactive-value="0"
active-color="#13ce66"
@change="Switch(scope,list)">
</el-switch>
</template>
</el-table-column>
<el-table-column label="推荐" align="center">
<template slot-scope="scope">
<el-switch
v-model="scope.row.is_recommend"
:active-value="1" :inactive-value="0"
active-color="#13ce66"
@change="Switch2(scope,list)">
</el-switch>
</template>
</el-table-column>
<el-table-column prop="isstate" label="操作">
<template slot-scope="scope">
<el-dropdown>
<el-button type="primary">
操作<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>
<el-button
type="text"
size="mini"
@click="displayComments(scope)">查看评论</el-button>
</el-dropdown-item>
<el-dropdown-item>
<el-button
type="text"
size="mini"
@click="del(scope,list)">删除</el-button>
</el-dropdown-item>
<el-dropdown-item v-if="scope.row.mid_ground_video_id>0">
<el-button
type="text"
size="mini"
@click="updateYzGoods(scope.row.id,scope.row.goods_id)">更新</el-button>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<el-row>
<el-col :span="24" align="right" migra style="padding:15px 5% 15px 0" v-loading="loading">
<el-pagination background layout="prev, pager, next" @current-change="currentChange" :total="page_total"
:page-size="page_size" :current-page="current_page"></el-pagination>
</el-col>
</el-row>
<el-dialog :visible.sync="is_open" class="video-sty">
<div style="text-align: center">
<video :src="videolist" controls="controls" style="max-width:600px;max-height: 800px;"></video>
</div>
</el-dialog>
</template>
<el-dialog :visible.sync="goods_show" width="60%" center title="选择商品">
<div>
<div style="text-align: center">
<el-input v-model="search_goods_keyword" style="width:80%"></el-input>
<el-button type="primary" @click="searchGoods()" style="margin-left:20px;">搜索</el-button>
</div>
<el-table :data="goods_list" style="width: 100%;height:500px;overflow:auto">
<el-table-column label="ID" prop="id" align="center"></el-table-column>
<el-table-column label="商品信息" align="center">
<template slot-scope="scope">
<div v-if="scope.row"
style="display:flex;align-items: center;justify-content:center;">
<img v-if="scope.row.thumb" :src="scope.row.thumb"
style="width:50px;height:50px"></img>
<div style="margin-left:10px">[[scope.row.title]]</div>
</div>
</template>
</el-table-column>
<el-table-column prop="refund_time" label="操作" align="center">
<template slot-scope="scope">
<el-button @click="sureGoods(scope.row)">
选择
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<el-row>
<el-col :span="24" align="right" migra style="padding:15px 5% 15px 0" v-loading="loading">
<el-pagination background layout="prev, pager, next" @current-change="goodsCurrentChange"
:total="goods_page_total"
:page-size="goods_page_size" :current-page="goods_current_page"></el-pagination>
</el-col>
</el-row>
</template>
<video-card :dialog-visible.sync="dialogVisible" :video_row="video_row" v-if="dialogVisible"></video-card>
</div>
@include('Yunshop\VideoShare::componemts.videoCard')
@include('public.admin.uploadMultimediaImg')
<script>
var vm = new Vue({
el:"#app",
delimiters: ['[[', ']]'],
data() {
let List = {!! $list?:'{}' !!}
let category = {!! $category?:'{}' !!}
console.log(List);
return{
is_open:false,
list:List.data,
loading:false,
page_total:List.total,
page_size:List.per_page,
current_page:List.current_page,
search_form:{
id:'{!! $_REQUEST['id'] !!}',
is_time:''
},
real_search_form:{},
search_loading:false,
seleceTime:'',
options:[
{
value:1,
label:'搜索发布时间'
},
{
value:0,
label:'不搜索发布时间'
}
],
categorys:category,
videolist:'',
change_title:'',
goods_show:false,
goods_list:[],
goods_page_total:0,
goods_page_size:0,
goods_current_page:0,
search_goods_keyword:'',
video_goods_id:0,
dialogVisible:false,
video_row:{},
}
},
mounted: function () {
},
methods: {
updateYzGoods(id,goods_id){
this.loading = true;
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.video-goods.update-yz-goods') !!}',{id:id,goods_id:goods_id}).then(function (response){
this.loading = false;
this.$message({message: response.data.msg, type: 'success'});
window.location.reload()
},function (response) {
this.loading = false;
this.$message({message: response.data.msg, type: 'error'});
}
);
},
video(id){//查询视频
this.is_open = true;
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.video-goods.video') !!}',{id:id}).then(function (response){
console.log(response.data.data);
this.videolist = response.data.data.video_src
},function (response) {
console.log(response);
}
);
},
currentChange(val) {
this.loading = true;
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.video-goods.search') !!}',{page:val,search:this.real_search_form}).then(function (response){
let data = response.data.data.list;
this.page_total = data.total;
this.list = data.data;
this.page_size = data.per_page;
this.current_page = data.current_page;
this.loading = false;
},function (response) {
console.log(response);
this.loading = false;
}
);
},
goodsShow(id) {
this.goods_show = true
this.video_goods_id = id
},
searchGoods() {
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.video-goods.get-good-list') !!}', {search: this.search_goods_keyword}
).then(function (response) {
console.log(response.data.data.data)
if (response.data.result) {
this.goods_list = response.data.data.data;
this.goods_page_total = response.data.data.total;
this.goods_page_size = response.data.data.per_page;
this.goods_current_page = response.data.data.current_page;
console.log(response.data.data)
} else {
console.log()
this.$message({message: response.data.msg, type: 'error'});
}
this.search_loading = false;
}
);
},
goodsCurrentChange(val) {
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.video-goods.get-good-list') !!}', {
page: val,
search: this.search_goods_keyword
}).then(function (response) {
this.goods_list = response.data.data.data;
this.goods_page_total = response.data.data.total;
this.goods_page_size = response.data.data.per_page;
this.goods_current_page = response.data.data.current_page;
this.loading = false;
}, function (response) {
// console.log(response);
this.loading = false;
}
);
},
sureGoods(rows) {
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.video-goods.edit-goods') !!}', {
goods_id: rows.id,
video_goods_id:this.video_goods_id
}).then(function (response) {
if (response.data.result){
this.$message.success("修改关联商品成功");
window.location.reload();
}else {
this.$message.error(response.data.msg);
}
}, function (response) {
this.$message.error(response.msg);
}
);
},
search() {
this.search_form.start_time='';
this.search_form.end_time='';
if(this.seleceTime===0){
this.search_form.is_time=0;
this.search_loading = true;
}
else{
this.search_loading = true;
this.search_form.is_time=1;
if(this.search_form.time){
this.search_form.is_time=1;
this.search_form.start_time = Math.round(this.search_form.time[0]/1000).valueOf();
this.search_form.end_time = Math.round(this.search_form.time[1]/1000).valueOf();
}
}
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.video-goods.search') !!}',{search:this.search_form}
).then(function (response) {
if (response.data.result){
let data = response.data.data.list;
this.page_total = data.total;
this.list = data.data;
this.page_size = data.per_page;
this.current_page = data.current_page;
this.loading = false;
this.real_search_form=Object.assign({},this.search_form);
}
else {
this.$message({message: response.data.msg,type: 'error'});
}
this.search_loading = false;
},function (response) {
this.search_loading = false;
this.$message({message: response.data.msg,type: 'error'});
}
);
},
del(scope, rows){
if(confirm("确认删除?")) {
rows.splice(scope.$index, 1);
let json={
id:scope.row.id
}
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.video-goods.del') !!}',json).then(function (response){
if (response.data.result) {
this.$message.success("删除成功");
} else {
this.$message({message: response.data.msg,type: 'error'});
}
},function (response) {
console.log(response);
this.loading = false;
}
);
}
},
titleChange(scope) {
let id = scope.row.id
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.video-goods.edit-title') !!}', {
id: id,
title: this.change_title
}).then(function (response) {
if (response.data.result){
this.$message.success("修改标题成功");
scope.row.title = this.change_title
} else {
this.$message({message: response.data.msg, type: 'error'});
}
}, function (response) {
this.$message({message: response.data.msg, type: 'error'});
}
);
},
displayComments(scope){
let id = scope.row.id
let url = "{!! yzWebUrl('plugin.video-share.admin.video-comments.display-comments') !!}&id=" + id
console.log(url)
window.location.href=url
},
Switch(scope, rows){
let json={
vid:scope.row.id
}
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.video-goods.changeStatus') !!}',json).then(function (response){
if (response.data.result){
this.$message.success("修改状态成功");
}
else{
this.$message({message: response.data.msg,type: 'error'});
}
},function (response) {
console.log(response);
this.loading = false;
}
);
},
Switch2(scope, rows){
let json={
vid:scope.row.id
}
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.video-goods.changeRecommend') !!}',json).then(function (response){
if (response.data.result){
this.$message.success("修改状态成功");
}
else{
this.$message({message: response.data.msg,type: 'error'});
}
},function (response) {
console.log(response);
this.loading = false;
}
);
},
changeCate(category_id, id){
let json={
category_id:category_id,
id:id
}
this.$http.post('{!! yzWebFullUrl('plugin.video-share.admin.video-goods.changeCategory') !!}',json).then(function (response){
if (response.data.result){
this.$message.success("修改成功");
}
else{
this.$message({message: response.data.msg,type: 'error'});
}
},function (response) {
console.log(response);
this.loading = false;
}
);
},
// 更换视频地址
replaceVideo(row) {
this.dialogVisible = true;
this.video_row = row;
}
},
});
</script>
@endsection

View File

@ -0,0 +1,61 @@
<div class='panel panel-default'>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">提现额度</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="withdraw[videoShare][roll_out_limit]" class="form-control"
value="{{$set['roll_out_limit']}}"/>
<span class="help-block">当前代理的佣金达到此额度时才能提现</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">提现手续费</label>
<div class="col-sm-9 col-xs-12">
<div class="switch">
<label class='radio-inline'>
<input type='radio' name='withdraw[videoShare][poundage_type]' value='1'
@if($set['poundage_type'] == 1) checked @endif />
固定金额
</label>
<label class='radio-inline'>
<input type='radio' name='withdraw[videoShare][poundage_type]' value='0'
@if(empty($set['poundage_type'])) checked @endif />
手续费比例
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-sm-9 col-xs-12">
<div class="cost">
<label class='radio-inline'>
<div class="input-group">
<div class="input-group-addon" id="videoShare_poundage_hint"
style="width: 120px;">@if($set['poundage_type'] == 1) 固定金额 @else
手续费比例 @endif</div>
<input type="text" name="withdraw[videoShare][poundage_rate]"
class="form-control" value="{{ $set['poundage_rate'] ?? '' }}"
placeholder="请输入提现手续费计算值"/>
<div class="input-group-addon" id="videoShare_poundage_unit">@if($set['poundage_type'] == 1) @else
% @endif</div>
</div>
</label>
</div>
</div>
</div>
</div>
<script language="javascript">
$(function () {
$(":radio[name='withdraw[videoShare][poundage_type]']").click(function () {
if ($(this).val() == 1) {
$("#videoShare_poundage_unit").html('元');
$("#videoShare_poundage_hint").html('固定金额');
}
else {
$("#videoShare_poundage_unit").html('%');
$("#videoShare_poundage_hint").html('手续费比例')
}
});
})
</script>

View File

@ -0,0 +1,61 @@
<div class='panel panel-default'>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">提现额度</label>
<div class="col-sm-9 col-xs-12">
<input type="text" name="withdraw[video_share_withdraw][roll_out_limit]" class="form-control"
value="{{$set['roll_out_limit']}}"/>
<span class="help-block">奖励金额达到此额度时才能提现</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label">提现手续费</label>
<div class="col-sm-9 col-xs-12">
<div class="switch">
<label class='radio-inline'>
<input type='radio' name='withdraw[video_share_withdraw][poundage_type]' value='1'
@if($set['poundage_type'] == 1) checked @endif />
固定金额
</label>
<label class='radio-inline'>
<input type='radio' name='withdraw[video_share_withdraw][poundage_type]' value='0'
@if(empty($set['poundage_type'])) checked @endif />
手续费比例
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
<div class="col-sm-9 col-xs-12">
<div class="cost">
<label class='radio-inline'>
<div class="input-group">
<div class="input-group-addon" id="video_share_withdraw_poundage_hint"
style="width: 120px;">@if($set['poundage_type'] == 1) 固定金额 @else
手续费比例 @endif</div>
<input type="text" name="withdraw[video_share_withdraw][poundage_rate]"
class="form-control" value="{{ $set['poundage_rate'] ?? '' }}"
placeholder="请输入提现手续费计算值"/>
<div class="input-group-addon" id="video_share_withdraw_poundage_unit">@if($set['poundage_type'] == 1) @else
% @endif</div>
</div>
</label>
</div>
</div>
</div>
</div>
<script language="javascript">
$(function () {
$(":radio[name='withdraw[video_share_withdraw][poundage_type]']").click(function () {
if ($(this).val() == 1) {
$("#video_share_withdraw_poundage_unit").html('元');
$("#video_share_withdraw_poundage_hint").html('固定金额');
}
else {
$("#video_share_withdraw_poundage_unit").html('%');
$("#video_share_withdraw_poundage_hint").html('手续费比例')
}
});
})
</script>