From 36bb257eff622165859b14ff39fefefa6e93963e Mon Sep 17 00:00:00 2001
From: wuhui_zzw <1760308791@qq.com>
Date: Wed, 13 Mar 2024 14:16:18 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E6=B6=88=E8=B4=B9?=
=?UTF-8?q?=E8=BF=94=E5=88=A9=20-=20=E5=95=86=E5=93=81=E7=9B=B8=E5=85=B3?=
=?UTF-8?q?=E8=AE=BE=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugins/rebate/src/PluginApplication.php | 19 ++
plugins/rebate/src/admin/IndexController.php | 24 +-
.../rebate/src/admin/widget/RebateWidget.php | 27 +++
plugins/rebate/src/models/GoodsRebate.php | 62 +++++
plugins/rebate/views/index/set.blade.php | 5 -
plugins/rebate/views/widget/profit/rebate.js | 218 ++++++++++++++++++
6 files changed, 333 insertions(+), 22 deletions(-)
create mode 100644 plugins/rebate/src/admin/widget/RebateWidget.php
create mode 100644 plugins/rebate/src/models/GoodsRebate.php
create mode 100644 plugins/rebate/views/widget/profit/rebate.js
diff --git a/plugins/rebate/src/PluginApplication.php b/plugins/rebate/src/PluginApplication.php
index dd2a74db..887be665 100644
--- a/plugins/rebate/src/PluginApplication.php
+++ b/plugins/rebate/src/PluginApplication.php
@@ -68,6 +68,25 @@ class PluginApplication extends \app\common\services\PluginApplication{
]);
}
+ public function getWidgetItems()
+ {
+ return [
+ 'vue-goods.rebate' => [
+ 'title' => '消费返利',
+ 'class' => \Yunshop\Rebate\admin\widget\RebateWidget::class,
+ ],
+ ];
+ }
+
+ protected function setConfig(){
+ \app\common\modules\shop\ShopConfig::current()->set(
+ 'observer.goods.rebate', [
+ 'class' => 'Yunshop\Rebate\models\GoodsRebate',
+ 'function_save' => 'relationSave'
+ ]
+ );
+ }
+
public function boot(){
$events = app('events');
diff --git a/plugins/rebate/src/admin/IndexController.php b/plugins/rebate/src/admin/IndexController.php
index ddfbf547..8119dd85 100644
--- a/plugins/rebate/src/admin/IndexController.php
+++ b/plugins/rebate/src/admin/IndexController.php
@@ -25,8 +25,13 @@ class IndexController extends BaseController{
return view('Yunshop\Rebate::index.index',$data)->render();
}
-
- // 基本设置
+ /**
+ * Common: 基本设置
+ * Author: wu-hui
+ * Time: 2024/03/13 10:47
+ * @return array|\Illuminate\Http\JsonResponse|string
+ * @throws \Throwable
+ */
public function set(){
// 获取设置信息 判断是否为设置
$setInfo = request()->input('rebate');
@@ -37,21 +42,6 @@ class IndexController extends BaseController{
}else{
// 获取信息
$set = Setting::get('plugin.rebate');
-
- // $start = "2024-3-31 12:12:59";
- // echo "购买时间:".$start."
";
- // for($i=1;$i <= 20;$i++){
- // $d = strtotime($start );
- // echo "第{$i}个月返利时间:".date("Y-m-d H:i:s",getNextMonthDays($d, $i))."
";
- // }
- // die;
-
-
-
-
-
-
-
return view('Yunshop\Rebate::index.set',[
'set' => $set,
])->render();
diff --git a/plugins/rebate/src/admin/widget/RebateWidget.php b/plugins/rebate/src/admin/widget/RebateWidget.php
new file mode 100644
index 00000000..4c622a0e
--- /dev/null
+++ b/plugins/rebate/src/admin/widget/RebateWidget.php
@@ -0,0 +1,27 @@
+where('goods_id', $this->goods->id)
+ ->first();
+ }
+
+ public function pagePath(){
+ return plugin_assets('rebate','views/widget');
+ }
+}
\ No newline at end of file
diff --git a/plugins/rebate/src/models/GoodsRebate.php b/plugins/rebate/src/models/GoodsRebate.php
new file mode 100644
index 00000000..825b235f
--- /dev/null
+++ b/plugins/rebate/src/models/GoodsRebate.php
@@ -0,0 +1,62 @@
+delete();
+ // 公共
+ $info->uniacid = \YunShop::app()->uniacid;
+ $info->goods_id = $goodsId;// 商品ID
+ $info->is_open = $data['is_open'] ?? 0;// 当前商品是否参与消费返利:0=未开启,1=开启
+ $info->is_alone = $data['is_alone'] ?? 0;// 是否独立设置:0=不是,1=是
+ $info->total_quarter = $data['total_quarter'] ?? 0;// 总多少季度
+ $info->quarter_list = json_encode($data['quarter_list'] ?? []);// 每季度配置信息
+
+ return $info->save();
+ }
+
+ public static function getModel($goodsId, $operate){
+ $model = false;
+ // 商品设置
+ if ($operate != 'created') $model = static::where(['goods_id' => $goodsId])->first();
+
+ !$model && $model = new static;
+
+ return $model;
+ }
+
+ public function getGoodsSet($goodsId){
+ self::where('goods_id', $goodsId);
+ }
+
+ //关联商品信息
+ public function belongsToGoods(){
+ return $this->belongsTo(Goods::class, 'goods_id', 'id');
+ }
+
+
+
+
+
+
+
+
+}
diff --git a/plugins/rebate/views/index/set.blade.php b/plugins/rebate/views/index/set.blade.php
index 1bd8ffd1..3a4c94d7 100644
--- a/plugins/rebate/views/index/set.blade.php
+++ b/plugins/rebate/views/index/set.blade.php
@@ -212,11 +212,6 @@
created() {},
mounted() {},
methods: {
- // 修改 每月返利金额
-
-
-
-
// 提交
onSubmit() {
let _this = this;
diff --git a/plugins/rebate/views/widget/profit/rebate.js b/plugins/rebate/views/widget/profit/rebate.js
new file mode 100644
index 00000000..df1ee49e
--- /dev/null
+++ b/plugins/rebate/views/widget/profit/rebate.js
@@ -0,0 +1,218 @@
+define({
+ name:"rebate",
+ template:`
+