zhangjidong 3 gün önce
ebeveyn
işleme
18557e7527
100 değiştirilmiş dosya ile 8732 ekleme ve 7764 silme
  1. 88 93
      models/AboutArticle.php
  2. 168 0
      models/AcPool.php
  3. 83 0
      models/AcPoolAwardRecord.php
  4. 68 0
      models/AcPoolDetail.php
  5. 74 74
      models/AccessoriesWorks.php
  6. 406 395
      models/AccountLog.php
  7. 103 71
      models/ActionLog.php
  8. 78 78
      models/ActivityCutPrice.php
  9. 37 37
      models/ActivityCutPriceBanner.php
  10. 37 37
      models/ActivityCutPriceCat.php
  11. 152 169
      models/ActivityCutPriceGoods.php
  12. 37 37
      models/ActivityCutPriceLog.php
  13. 88 88
      models/ActivityCutPriceOrder.php
  14. 107 107
      models/ActivityNewUser.php
  15. 193 193
      models/ActivityNewUserGoods.php
  16. 107 131
      models/ActivityOrderRebateSelf.php
  17. 62 62
      models/ActivityOrderRebateSelfGoods.php
  18. 75 75
      models/ActivityOrderRebateSelfLevel.php
  19. 37 37
      models/ActivityOrderRebateSelfLog.php
  20. 37 60
      models/ActivityOrderRebateSelfOrder.php
  21. 37 37
      models/ActivityOrderRebateSelfUser.php
  22. 70 70
      models/ActivityOrdervoucher.php
  23. 128 128
      models/ActivityRebateOrderN.php
  24. 225 225
      models/ActivityRebateOrderNLog.php
  25. 101 101
      models/ActivityWechatRoom.php
  26. 84 84
      models/ActivityWechatRoomGoods.php
  27. 114 114
      models/Address.php
  28. 254 265
      models/Admin.php
  29. 39 39
      models/AdminRole.php
  30. 55 55
      models/AdoptGoodsDevice.php
  31. 69 69
      models/AgentApply.php
  32. 57 57
      models/AgentBind.php
  33. 83 99
      models/AgentFrontBind.php
  34. 57 57
      models/AgentFrontErpCloudGoods.php
  35. 133 133
      models/AgentFrontErpInventory.php
  36. 41 41
      models/AgentFrontErpInventoryLog.php
  37. 41 41
      models/AgentFrontErpPurchase.php
  38. 82 82
      models/AgentFrontErpPurchaseOrder.php
  39. 51 51
      models/AgentFrontErpPurchasein.php
  40. 37 37
      models/AgentFrontErpPurchaseinOrder.php
  41. 51 51
      models/AgentFrontErpPurchaseout.php
  42. 37 37
      models/AgentFrontErpPurchaseoutOrder.php
  43. 59 59
      models/AgentGoodsBindGoods.php
  44. 63 63
      models/AgentGoodsInstallLog.php
  45. 73 73
      models/AggregateQrcode.php
  46. 74 0
      models/AggregateQrcodeNew.php
  47. 58 58
      models/AggregateSaasQrcode.php
  48. 59 0
      models/AggregateSaasQrcodeNew.php
  49. 54 54
      models/AliMiniSign.php
  50. 172 172
      models/AlipayAcitvityVoucherCoupon.php
  51. 136 136
      models/AlipayAcitvityVoucherOrder.php
  52. 85 85
      models/AlipayActivityDelivery.php
  53. 41 41
      models/AlipayCard.php
  54. 41 41
      models/AlipayCardTemp.php
  55. 54 54
      models/AlipayMarketingMaterial.php
  56. 162 162
      models/AlipaySharingReceiver.php
  57. 59 59
      models/AlipayVoucherCode.php
  58. 53 53
      models/AlipayVoucherCodeTask.php
  59. 62 0
      models/AllDistrictAgent.php
  60. 64 0
      models/AllDistrictOrder.php
  61. 138 0
      models/AllianceCouponSettle.php
  62. 68 0
      models/AllianceCouponSettleDetail.php
  63. 133 133
      models/AppNavbar.php
  64. 65 65
      models/Article.php
  65. 55 55
      models/Attr.php
  66. 64 64
      models/AttrGroup.php
  67. 107 114
      models/AttrLibrary.php
  68. 85 85
      models/AuthRole.php
  69. 107 107
      models/Banner.php
  70. 55 55
      models/BonusPool.php
  71. 59 59
      models/BonusPoolDetail.php
  72. 61 72
      models/BonusPoolLevel.php
  73. 45 45
      models/BookingGoodsCat.php
  74. 56 56
      models/BookingGoodsExt.php
  75. 112 112
      models/BookingOrderExt.php
  76. 64 64
      models/BrowseLog.php
  77. 49 49
      models/BusinessCart.php
  78. 62 63
      models/BusinessMember.php
  79. 100 105
      models/BusinessMemberOrder.php
  80. 73 73
      models/BusinessRightDuration.php
  81. 77 77
      models/BusinessRightInfo.php
  82. 106 106
      models/BuyGoodsLog.php
  83. 88 88
      models/Card.php
  84. 47 47
      models/CardSend.php
  85. 73 76
      models/Cart.php
  86. 61 61
      models/CartOffline.php
  87. 290 676
      models/Cash.php
  88. 59 59
      models/CashierGoodsPriceLog.php
  89. 177 172
      models/Cat.php
  90. 85 85
      models/Clerk.php
  91. 84 84
      models/Cloud.php
  92. 67 67
      models/CloudGoodsBind.php
  93. 63 63
      models/CloudGoodsUpdateLog.php
  94. 62 0
      models/CloudInventory.php
  95. 83 0
      models/CloudInventoryBalanceLog.php
  96. 65 0
      models/CloudInventoryCash.php
  97. 49 0
      models/CloudInventoryCat.php
  98. 62 0
      models/CloudInventoryDeductPurchaseMoneyLog.php
  99. 179 0
      models/CloudInventoryGoods.php
  100. 145 0
      models/CloudInventoryGoodsBind.php

+ 88 - 93
models/AboutArticle.php

@@ -1,93 +1,88 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use app\jobs\storeSync\DiyCommon;
-use Yii;
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-/**
- * This is the model class for table "{{%topic_type}}".
- *
- * @property int $id
- * @property int|null $store_id
- * @property string|null $name
- * @property string|null $desc
- * @property int|null $sort
- * @property int|null $is_delete
- * @property int|null $created_at 添加时间
- * @property int|null $updated_at 更新时间
- * @property int $type
- */
-class AboutArticle extends \yii\db\ActiveRecord
-{
-    const IS_DELETE_YES = 1;//已删除
-    const IS_DELETE_NO = 0;//未删除
-
-    const TYPE_SERVICE = 2;
-    const TYPE_PRIVACY = 3;
-    const TYPE_ABOUT_US = 4;
-
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%about_article}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['sort', 'is_delete', 'store_id', 'created_at', 'updated_at', 'type'], 'integer'],
-            [['name'], 'string', 'max' => 255],
-            [['desc'], 'string']
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'name' => 'Name',
-            'desc' => '文章详情',
-            'sort' => 'Sort',
-            'is_delete' => 'Is Delete',
-            'store_id' => 'Store ID',
-            'created_at' => 'created_at',
-            'updated_at' => 'updated_at',
-            'type' => '文章类型'
-        ];
-    }
-
-    public function afterSave($insert, $changedAttributes)
-    {
-        parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
-        (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_ARTICLE);
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use app\jobs\storeSync\DiyCommon;
+use Yii;
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+/**
+ * This is the model class for table "{{%topic_type}}".
+ *
+ * @property int $id
+ * @property int|null $store_id
+ * @property string|null $name
+ * @property string|null $desc
+ * @property int|null $sort
+ * @property int|null $is_delete
+ * @property int|null $created_at 添加时间
+ * @property int|null $updated_at 更新时间
+ * @property int $type
+ */
+class AboutArticle extends \yii\db\ActiveRecord
+{
+    const IS_DELETE_YES = 1;//已删除
+    const IS_DELETE_NO = 0;//未删除
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%about_article}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['sort', 'is_delete', 'store_id', 'created_at', 'updated_at', 'type'], 'integer'],
+            [['name'], 'string', 'max' => 255],
+            [['desc'], 'string']
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'name' => 'Name',
+            'desc' => '文章详情',
+            'sort' => 'Sort',
+            'is_delete' => 'Is Delete',
+            'store_id' => 'Store ID',
+            'created_at' => 'created_at',
+            'updated_at' => 'updated_at',
+            'type' => '文章类型'
+        ];
+    }
+
+    public function afterSave($insert, $changedAttributes)
+    {
+        parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
+        (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_ARTICLE);
+    }
+
+}

+ 168 - 0
models/AcPool.php

@@ -0,0 +1,168 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+
+namespace app\models;
+
+use app\constants\OptionSetting;
+use app\modules\alliance\models\CurrencyForm;
+use app\plugins\scanCodePay\models\Order as ScanCodePayOrder;
+use app\plugins\scanCodePay\models\Order as ScanOrder;
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+use Yii;
+use yii\helpers\Json;
+
+/**
+ * This is the model class for table "{{%ac_pool}}".
+ *
+ * @property integer $id
+ * @property integer $main_currency_id
+ * @property integer $currency_id
+ * @property integer $start_time
+ * @property integer $end_time
+ * @property float $money
+ * @property float $rate
+ * @property double $dividend_amount
+ * @property double $balance_amount
+ * @property integer $is_send
+ * @property integer $is_scan
+ * @property integer $send_time
+ * @property integer $created_at
+ * @property integer $updated_at
+ */
+class AcPool extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%ac_pool}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['is_send', 'send_time', 'start_time', 'end_time', 'is_scan', 'currency_id', 'main_currency_id'], 'integer'],
+            [['money', 'balance_amount', 'dividend_amount', 'rate'], 'number'],
+            [['created_at', 'updated_at'], 'safe']
+        ];
+    }
+
+    /**
+     * 增加合伙人分红池
+     * @param $order
+     * @param $money
+     * @param string $desc
+     * @return false|void
+     */
+    public static function poolPush($order, $money, $desc = '', $pay_price = 0, $model = 0)
+    {
+        $is_scan = $order instanceof ScanCodePayOrder ? 1 : 0;
+        //debug_log([__METHOD__, __LINE__, "执行acpoolpush"], "app_debug.log");
+        $form = new CurrencyForm();
+        $data = $form->Inertupdate_bonus($order->id,$is_scan);
+        //debug_log([__METHOD__, __LINE__, "===订单id:".$order->id.',payprice:'.$pay_price], "app_debug.log");
+        foreach ($data as $i){
+            $dividend = $i['dividend'];
+            foreach ($dividend as $j){
+                $pool = self::find()->where(['and',['<', 'start_time', time()],['>=', 'end_time', time()],['=', 'is_send', 0],['=', 'currency_id', $j['id']]])
+                    ->orderBy(['id' => SORT_DESC])->one();
+
+                //debug_log([__METHOD__, __LINE__, "---------------- 开始插入分红池1 -------------------currency_id".$j['id']], "app_debug.log");
+
+                // 如果没有奖金池,重新创建奖金池
+                if (!$pool) {
+                    $time_data = self::getTime($j['id']);
+                    $pool = new self();
+                    $pool->start_time = $time_data['start_time'];
+                    $pool->main_currency_id = $i['main_currency_id'];
+                    $pool->currency_id = $j['id'];
+                    $pool->rate= $j['percent'];
+                    $pool->end_time = $time_data['end_time'];
+                    $pool->is_send = 0;
+                    $pool->send_time = 0;
+                }
+                $before_money = $pool->money ? $pool->money : 0;
+                $add_money = $money*$j['percent']/100;
+                $pool->money += $add_money;
+
+                if (!$pool->save()) {
+                    //debug_log([__METHOD__, __LINE__, "---------------- 合伙人奖金池更新失败 -------------------" . json_encode($pool->errors)], "app_debug.log");
+                    return false;
+                }
+                $pool_log = new AcPoolDetail();
+                $pool_log->order_id = $order->id;
+                $pool_log->currency_id = $j['id'];
+                $pool_log->order_no = $order->order_no;
+                $pool_log->pay_price = $is_scan ? $pay_price : $order->pay_price+$order->take_price;
+                $pool_log->store_id = $order->store_id;
+                $pool_log->before_money = $before_money;
+                $pool_log->after_money = $pool->money;
+                $pool_log->total_pv = $money;
+                $pool_log->money = $add_money;
+                $pool_log->total_price = $order->total_price;
+                $pool_log->is_scan = $is_scan;
+                $pool_log->pool_id = $pool->id;
+                $pool_log->model_type = $model;
+                $pool_log->desc = '订单号:' . $order->order_no . '追加';
+                if (!$pool_log->save()) {
+                    //debug_log([__METHOD__, __LINE__, "---------------- 奖金池记录保存失败 -------------------" . json_encode($pool_log->errors)], "app_debug.log");
+                    return false;
+                }
+            }
+
+        }
+
+        //debug_log([__METHOD__, __LINE__, "---------------- 开始插入分红池结束 -------------------"], "app_debug.log");
+    }
+
+    public static function getTime($currency_id)
+    {
+        $data = Option::getDecode('currency_dividend_time',$currency_id,'currency');//使用币种id代替store_id
+        $interval = $data['interval'] ?? 1;
+        $timeunit = $data['timeunit'];
+
+        if (!in_array($timeunit,['minute','hour','day','month'])) $timeunit = 'day';
+        switch ($timeunit){
+            case 'minute':
+                $time = strtotime(date('Y-m-d H:i:00', time()));
+                break;
+            case 'hour':
+                $time = strtotime(date('Y-m-d H:00:00', time()));
+                break;
+            case 'month':
+                $time = strtotime(date('Y-m-1', time()));
+                break;
+            default:
+                $time = strtotime(date('Y-m-d', time()));
+                break;
+        }
+        return [
+            'start_time' => $time,
+            'end_time' => strtotime('+'.$interval.' '.$timeunit,$time)
+        ];
+
+    }
+}

+ 83 - 0
models/AcPoolAwardRecord.php

@@ -0,0 +1,83 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\base\ErrorException;
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%ac_pool_award_record}}".
+ *
+ * @property integer $id
+ * @property integer $currency_id
+ * @property integer $money
+ * @property integer $pool_id
+ * @property integer $saas_id
+ * @property string $weight
+ * @property string $fee
+ * @property string $miss_money
+ * @property string  $desc
+ * @property integer $created_at
+ */
+class AcPoolAwardRecord extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%ac_pool_award_record}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [[ 'pool_id', 'saas_id','currency_id'], 'integer'],
+            [['desc'], 'string'],
+            [['money','weight','miss_money','fee'], 'number'],
+            [['created_at'], 'safe']
+        ];
+    }
+
+    public static function createRecord($currency_id,$saas_id,$pool_id,$weight,$desc,$money,$fee,$miss){
+        try {
+            $record = new self();
+            $record->money=$money;
+            $record->currency_id=$currency_id;
+            $record->pool_id=$pool_id;
+            $record->saas_id=$saas_id;
+            $record->weight=$weight?:0;
+            $record->fee=$fee?:0;
+            $record->miss_money=$miss?:0;
+            $record->desc=$desc;
+            if (!$record->save())throw new ErrorException('保存失败'.json_encode($record->getErrors()));
+            return true;
+        }catch (ErrorException $e){
+            //debug_log([__METHOD__, __LINE__, "发放是失败 {$e->getMessage() }"], "app_debug_partner.log");
+            return false;
+        }
+
+    }
+}

+ 68 - 0
models/AcPoolDetail.php

@@ -0,0 +1,68 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%ac_pool_detail}}".
+ *
+ * @property integer $id
+ * @property integer $currency_id
+ * @property integer $order_id
+ * @property integer $store_id
+ * @property string $order_no
+ * @property integer $is_scan
+ * @property integer $money
+ * @property integer $pool_id
+ * @property string  $desc
+ * @property integer $created_at
+ * @property float $before_money
+ * @property float $after_money
+ * @property float $pay_price
+ * @property float $total_pv
+ * @property float $total_price
+ * @property integer $model_type
+ */
+class AcPoolDetail extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%ac_pool_detail}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['order_id', 'pool_id', 'is_scan','model_type','store_id','currency_id'], 'integer'],
+            [['desc', 'order_no'], 'string'],
+            [['money','pay_price','total_price','total_pv','before_money','after_money'], 'number'],
+            [['created_at'], 'safe']
+        ];
+    }
+}

+ 74 - 74
models/AccessoriesWorks.php

@@ -1,75 +1,75 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-
-namespace app\models;
-
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * Class Cat
- * @package app\modules\models
- * @property integer $id
- * @property integer $store_id
- * @property integer $user_id
- * @property string $user_name
- * @property string $image
- * @property string $goods_ids
- * @property integer $created_at
- * @property integer $updated_at
- */
-class AccessoriesWorks extends ActiveRecord
-{
-    /**
-     * 分类是否显示:显示
-     */
-    const IS_SHOW_TRUE = 1;
-
-    /**
-     * 分类是否显示:不显示
-     */
-    const IS_SHOW_FALSE = 0;
-
-    public function behaviors()
-    {
-        return [
-            [
-                // 自动更新创建和更新时间
-                'class' => TimestampBehavior::class,
-                'value' => time()
-            ]
-        ];
-    }
-
-    public static function tableName()
-    {
-        return '{{%accessories_works}}';
-    }
-
-    public function rules()
-    {
-        return [
-            [['store_id',  'image'], 'required'],
-            [['store_id', 'created_at', 'user_id','updated_at'], 'integer'],
-            [['user_name','image','goods_ids'], 'string', 'max' => 255],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => '商城id',
-            'user_id' => '用户ID',
-            'user_name' => '用户昵称',
-            'image' => '场景图片',
-            'goods_ids' => '关联商品ID',
-            'created_at' => '创建时间',
-            'updated_at' => '更新时间'
-        ];
-    }
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+
+namespace app\models;
+
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * Class Cat
+ * @package app\modules\models
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $user_id
+ * @property string $user_name
+ * @property string $image
+ * @property string $goods_ids
+ * @property integer $created_at
+ * @property integer $updated_at
+ */
+class AccessoriesWorks extends ActiveRecord
+{
+    /**
+     * 分类是否显示:显示
+     */
+    const IS_SHOW_TRUE = 1;
+
+    /**
+     * 分类是否显示:不显示
+     */
+    const IS_SHOW_FALSE = 0;
+
+    public function behaviors()
+    {
+        return [
+            [
+                // 自动更新创建和更新时间
+                'class' => TimestampBehavior::class,
+                'value' => time()
+            ]
+        ];
+    }
+
+    public static function tableName()
+    {
+        return '{{%accessories_works}}';
+    }
+
+    public function rules()
+    {
+        return [
+            [['store_id',  'image'], 'required'],
+            [['store_id', 'created_at', 'user_id','updated_at'], 'integer'],
+            [['user_name','image','goods_ids'], 'string', 'max' => 255],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => '商城id',
+            'user_id' => '用户ID',
+            'user_name' => '用户昵称',
+            'image' => '场景图片',
+            'goods_ids' => '关联商品ID',
+            'created_at' => '创建时间',
+            'updated_at' => '更新时间'
+        ];
+    }
 }

+ 406 - 395
models/AccountLog.php

@@ -1,395 +1,406 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use app\modules\admin\models\wechat_mp\CardForm;
-use app\utils\IotCloudHelper;
-
-/**
- * This is the model class for table "{{%account_log}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $order_type
- * @property integer $order_id
- * @property integer $user_id
- * @property integer $amount
- * @property string  $desc
- * @property integer $before
- * @property integer $after
- * @property string  $operator
- * @property integer $operator_id
- * @property integer $log_type
- * @property integer $type
- * @property integer $operator_type
- * @property string  $pic_url
- * @property string  $explain
- * @property integer $created_at
- * @property integer $from
- * @property integer $from_user_id
- * @property integer $profit
- * @property integer $saas_id
- */
-class AccountLog extends \yii\db\ActiveRecord
-{
-
-
-    /**
-     * 收入类型
-     */
-    CONST LOG_TYPE_INCOME = 1;
-    /**
-     * 支出类型
-     */
-    CONST LOG_TYPE_EXPEND = 2;
-
-    public static $type_budget = [
-        self::LOG_TYPE_INCOME,
-        self::LOG_TYPE_EXPEND
-    ];
-
-    /**
-     * 充值订单
-     */
-    CONST TYPE_RECHARGE_ORDER = 0;
-    /**
-     * 商城订单
-     */
-    CONST TYPE_PLATFORM_ORDER = 1;
-    /**
-     * 秒杀订单
-     */
-    CONST TYPE_MS_ORDER = 2;
-    /**
-     * 拼团订单
-     */
-    CONST TYPE_PT_ORDER = 3;
-    /**
-     * 商城订单退款
-     */
-    CONST TYPE_PLATFORM_REFUND_ORDER = 4;
-    /**
-     * 充值订单退款(减余额)
-     */
-    CONST TYPE_RECHARGE_REFUND_ORDER = 41;
-    /**
-     * 商城秒杀退款
-     */
-    CONST TYPE_MS_REFUND_ORDER = 5;
-    /**
-     * 商城拼团退款
-     */
-    CONST TYPE_PT_REFUND_ORDER = 6;
-
-    /**
-     * 商城预约退款
-     */
-    CONST TYPE_YY_REFUND_ORDER = 7;
-
-    /**
-     * 预约订单
-     */
-    CONST TYPE_YY_ORDER = 8;
-
-    /**
-     * 预约订单
-     */
-    CONST TYPE_SCRATCH_ORDER = 9;
-
-    /**
-     * 大转盘
-     */
-    CONST TYPE_POND_ORDER = 10;
-
-    /**
-     * 供货商订单
-     */
-    CONST TYPE_SUPPLIER_ORDER = 11;
-
-    /**
-     * 会员购买订单
-     */
-    CONST TYPE_LEVEL_ORDER = 12;
-
-    /**
-     * 当面付
-     */
-    CONST TYPE_SCAN_CODE_PAY = 13;
-
-    /**
-     * saas积分商品订单
-     */
-    CONST TYPE_SAAS_INTEGRAL_ORDER = 14;
-
-    /**
-     * saas积分商品订单
-     */
-    CONST TYPE_BALANCE_TO_COMMISSION = 15;
-
-    /**
-     * 签到送积分
-     */
-    CONST TYPE_REGISTER_INTEGRAL = 16;
-    /**
-     * 问答专区提问
-     */
-    CONST TYPE_QUESTION_INTEGRAL = 17;
-    /**
-     * 问答专区看视频广告
-     */
-    const TYPE_QUESTION_AD = 18;
-    /**
-     * 充值上级佣金
-     */
-    const TYPE_RECHARGE_COMMISSION = 20;
-    /**
-     * 充值分销佣金
-     */
-    const TYPE_DISTRIBUTION_COMMISSION = 21;
-
-    /**
-     * p大转盘抽奖
-     */
-    const TYPE_POND_COMMISSION = 23;
-
-    /**
-     * 提现类型佣金
-     */
-    const TYPE_CASH = 24;
-
-    /**
-     * 短视频积分奖励
-     */
-    const VIDEO_GOODS_REWARDS = 26;
-
-    /**
-     * 余额
-     */
-    const TYPE_BALANCE = 2;
-    /**
-     * 积分
-     */
-    const TYPE_INTEGRAL = 1;
-    /**
-     * 商品余额抵扣
-     */
-    const TYPE_GOODS_BALANCE = 19;
-    /**
-     * 微信
-     */
-    CONST TYPE_WECHAT = 3;
-
-    /**
-     * 增值积分
-     */
-    CONST TYPE_INTEGRAL_POOL = 50;
-
-    /**
-     * 支付宝
-     */
-    CONST TYPE_ALIPAY = 4;
-
-    public static $valid_type = [
-        self::TYPE_BALANCE,
-        self::TYPE_INTEGRAL,
-        self::TYPE_WECHAT,
-        self::TYPE_ALIPAY,
-        self::TYPE_INTEGRAL_POOL,
-    ];
-
-    /**
-     * 后台改动
-     */
-    CONST TYPE_OPERATOR_BACK = 2;
-    /**
-     * 前台变化
-     */
-    CONST TYPE_OPERATOR_NORMAL= 1;
-
-    public static $type_order = [
-        self::TYPE_RECHARGE_ORDER,
-        self::TYPE_PLATFORM_ORDER,
-        self::TYPE_MS_ORDER,
-        self::TYPE_PT_ORDER,
-        self::TYPE_PLATFORM_REFUND_ORDER,
-        self::TYPE_MS_REFUND_ORDER,
-        self::TYPE_PT_REFUND_ORDER
-    ];
-
-
-    const ORDER_TYPE_FACE_PAY = 25;
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%account_log}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['user_id', 'type', 'amount', 'desc', 'order_type', 'before', 'after',
-                'operator_type', 'log_type', 'type'], 'required'],
-            [['user_id', 'type', 'created_at', 'order_type', 'order_id', 'operator_type', 'log_type', 'operator_id', 'from', 'from_user_id', 'saas_id'
-                ], 'integer'],
-            [['amount', 'before', 'after', 'profit'], 'number'],
-            [['desc', 'pic_url', 'explain', 'operator'], 'string'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'user_id' => 'User ID',
-            'log_type' => '类型:1=收入,2=支出',
-            'type' => '类型:2=余额,1=积分',
-            'amount' => '变动数',
-            'desc' => '变动说明',
-            'before' => '变动前',
-            'after' => '变动后',
-            'operator' => '操作者',
-            'operator_id' => '操作者id',
-            'operator_type' => '1:前台,2:后台',
-            'pic_url' => '图片',
-            'explain' => '说明',
-            'created_at' => '添加时间',
-            'order_type' => '订单类型 0--充值 1--商城订单 2--秒杀订单 3--拼团订单 4--商城订单退款 5--秒杀订单退款 6--拼团订单退款 7--后台改动,15、团购券, 23、大转盘抽奖 24提现 25--当面付积分',
-            'order_id' => '订单ID',
-            'from' => '是否为转增',
-            'saas_id' => '联盟用户'
-        ];
-    }
-
-    /**
-     * 仅适用客户端使用
-     * @param $user_id
-     * @param $amount
-     * @param $type
-     * @param $log_type
-     * @param int $order_type
-     * @param int $order_id
-     * @param string $desc
-     * @return bool
-     */
-    public static function saveLog($user_id, $amount, $type, $log_type, $order_type = 0, $order_id = 0, $desc = "", $from = 0, $from_user_id = 0, $profit = 0)
-    {
-        $form = new self();
-        $user_info = User::findOne($user_id);
-        $form->store_id = $user_info->store_id;
-        $form->user_id = $user_id;
-        $form->amount = $amount;
-        $form->type = $type;
-        $form->before = $type == AccountLog::TYPE_INTEGRAL ? $user_info->integral : $user_info->money;
-        if ($log_type == AccountLog::LOG_TYPE_INCOME) {
-            if ($type == AccountLog::TYPE_INTEGRAL) {
-                $form->after = $user_info->integral + $amount;
-            } else {
-                $form->after = $user_info->money + $amount;
-            }
-        } else {
-            if ($type == AccountLog::TYPE_INTEGRAL) {
-                $form->after = $user_info->integral - $amount;
-            } else {
-                $form->after = $user_info->money - $amount;
-            }
-        }
-        $form->desc = $desc;
-        $form->order_type = $order_type;
-        $form->order_id = $order_id;
-        $form->operator = '';
-        $form->operator_id = 0;
-        $form->log_type = $log_type;
-        $form->operator_type = AccountLog::TYPE_OPERATOR_NORMAL;
-        $form->created_at = time();
-        if ($from) {
-            $form->from = $from;
-        }
-        if ($from_user_id) {
-            $form->from_user_id = $from_user_id;
-        }
-        if ($profit) {
-            $form->profit = $profit;
-        }
-        if ($form->save()) {
-            if ($type == AccountLog::TYPE_INTEGRAL) {
-                if ($log_type == AccountLog::LOG_TYPE_INCOME) {
-                    $user_info->updateCounters(['integral' => $amount]);
-                } else {
-                    $user_info->updateCounters(['integral' => -$amount]);
-                }
-            } else {
-                if ($log_type == AccountLog::LOG_TYPE_INCOME) {
-                    $user_info->updateCounters(['money' => $amount]);
-                } else {
-                    $user_info->updateCounters(['money' => -$amount]);
-                }
-            }
-
-            return true;
-        }
-    }
-
-    public function afterSave($insert, $changedAttributes)
-    {
-        parent::afterSave($insert, $changedAttributes);
-        if ($insert) {
-            self::wxCardSync($this, $changedAttributes);
-            self::voiceSendMessage($this);
-        }
-    }
-
-    public static function wxCardSync($form, $ca = [])
-    {
-        \Yii::error([__METHOD__, $form, $ca]);
-        if ($form->type != AccountLog::TYPE_INTEGRAL) {
-            return true;
-        }
-        $cf = new CardForm();
-        $bind = $cf->getBindByUserId($form->user_id, $form->store_id);
-        if (!$bind) {
-            return true;
-        }
-        $amount = $form->amount;
-        if ($form->log_type != AccountLog::LOG_TYPE_INCOME) {
-            $amount = -$amount;
-        }
-        $cf->updateUser($bind, [
-            "record_bonus" => $form->desc,
-            "bonus" => $form->after,
-            "add_bonus" => $amount,
-        ]);
-        return true;
-    }
-
-    // 余额支付语音播报
-    public static function voiceSendMessage($form)
-    {
-        if (
-            $form->log_type == self::LOG_TYPE_EXPEND &&
-            $form->type == self::TYPE_BALANCE &&
-            $form->operator_type == self::TYPE_OPERATOR_NORMAL &&
-            $form->order_id > 0
-        ) {
-            $store = Store::findOne($form->store_id);
-            if ($store && !empty($store->device_name)) {
-                $total_fee = $form->amount;
-                IotCloudHelper::sendMessage($form->store_id, '{"cmd":"voice","msg":"会员卡消费收款'.$total_fee.'元","msgid":"'.$form->created_at . $form->order_id.'"}');
-            }
-        }
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use app\modules\admin\models\wechat_mp\CardForm;
+use app\utils\IotCloudHelper;
+
+/**
+ * This is the model class for table "{{%account_log}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $order_type
+ * @property integer $order_id
+ * @property integer $user_id
+ * @property integer $amount
+ * @property string  $desc
+ * @property integer $before
+ * @property integer $after
+ * @property string  $operator
+ * @property integer $operator_id
+ * @property integer $log_type
+ * @property integer $type
+ * @property integer $operator_type
+ * @property string  $pic_url
+ * @property string  $explain
+ * @property integer $created_at
+ * @property integer $from
+ * @property integer $from_user_id
+ * @property integer $profit
+ * @property integer $saas_id
+ */
+class AccountLog extends \yii\db\ActiveRecord
+{
+
+
+    /**
+     * 收入类型
+     */
+    CONST LOG_TYPE_INCOME = 1;
+    /**
+     * 支出类型
+     */
+    CONST LOG_TYPE_EXPEND = 2;
+
+    public static $type_budget = [
+        self::LOG_TYPE_INCOME,
+        self::LOG_TYPE_EXPEND
+    ];
+
+    /**
+     * 充值订单
+     */
+    CONST TYPE_RECHARGE_ORDER = 0;
+    /**
+     * 商城订单
+     */
+    CONST TYPE_PLATFORM_ORDER = 1;
+    /**
+     * 秒杀订单
+     */
+    CONST TYPE_MS_ORDER = 2;
+    /**
+     * 拼团订单
+     */
+    CONST TYPE_PT_ORDER = 3;
+    /**
+     * 商城订单退款
+     */
+    CONST TYPE_PLATFORM_REFUND_ORDER = 4;
+    /**
+     * 充值订单退款(减余额)
+     */
+    CONST TYPE_RECHARGE_REFUND_ORDER = 41;
+    /**
+     * 商城秒杀退款
+     */
+    CONST TYPE_MS_REFUND_ORDER = 5;
+    /**
+     * 商城拼团退款
+     */
+    CONST TYPE_PT_REFUND_ORDER = 6;
+
+    /**
+     * 商城预约退款
+     */
+    CONST TYPE_YY_REFUND_ORDER = 7;
+
+    /**
+     * 预约订单
+     */
+    CONST TYPE_YY_ORDER = 8;
+
+    /**
+     * 预约订单
+     */
+    CONST TYPE_SCRATCH_ORDER = 9;
+
+    /**
+     * 大转盘
+     */
+    CONST TYPE_POND_ORDER = 10;
+
+    /**
+     * 供货商订单
+     */
+    CONST TYPE_SUPPLIER_ORDER = 11;
+
+    /**
+     * 会员购买订单
+     */
+    CONST TYPE_LEVEL_ORDER = 12;
+
+    /**
+     * 当面付
+     */
+    CONST TYPE_SCAN_CODE_PAY = 13;
+
+    /**
+     * saas积分商品订单
+     */
+    CONST TYPE_SAAS_INTEGRAL_ORDER = 14;
+
+    /**
+     * saas积分商品订单
+     */
+    CONST TYPE_BALANCE_TO_COMMISSION = 15;
+
+    /**
+     * 签到送积分
+     */
+    CONST TYPE_REGISTER_INTEGRAL = 16;
+    /**
+     * 问答专区提问
+     */
+    CONST TYPE_QUESTION_INTEGRAL = 17;
+    /**
+     * 问答专区看视频广告
+     */
+    const TYPE_QUESTION_AD = 18;
+    /**
+     * 充值上级佣金
+     */
+    const TYPE_RECHARGE_COMMISSION = 20;
+    /**
+     * 充值分销佣金
+     */
+    const TYPE_DISTRIBUTION_COMMISSION = 21;
+
+    /**
+     * p大转盘抽奖
+     */
+    const TYPE_POND_COMMISSION = 23;
+    /**
+     * 采购金
+     */
+    const TYPE_CLOUD_INVENTORY_PURCHASE_MONEY = 25;
+    const TYPE_PURCHASE_CLOUD_INVENTORY_PURCHASE_MONEY = 26;
+
+    /**
+     * 贡献积分
+     */
+    const TYPE_COIN = 3;
+    /**
+     * 余额
+     */
+    const TYPE_BALANCE = 2;
+    /**
+     * 积分
+     */
+    const TYPE_INTEGRAL = 1;
+    /**
+     * 商品余额抵扣
+     */
+    const TYPE_GOODS_BALANCE = 19;
+    /**
+     * 微信
+     */
+    CONST TYPE_WECHAT = 3;
+
+    /**
+     * 支付宝
+     */
+    CONST TYPE_ALIPAY = 4;
+    /**
+     * 采购金
+     */
+    CONST TYPE_PURCHASE_MONEY = 5;
+
+    public static $valid_type = [
+        self::TYPE_BALANCE,
+        self::TYPE_INTEGRAL,
+        self::TYPE_WECHAT,
+        self::TYPE_ALIPAY,
+        self::TYPE_PURCHASE_MONEY
+    ];
+
+    /**
+     * 后台改动
+     */
+    CONST TYPE_OPERATOR_BACK = 2;
+    /**
+     * 前台变化
+     */
+    CONST TYPE_OPERATOR_NORMAL= 1;
+    /**
+     * AI变化
+     */
+    CONST TYPE_OPERATOR_AI= 3;
+
+    /**
+     * @var int[]
+     */
+    CONST FROM_TYPE_ORIGINAL = 0; //原始
+    CONST FROM_TYPE_GIFT = 1; //赠送
+    CONST FROM_TYPE_GIFTED_GIFT = 1; //被赠送
+    CONST FROM_TYPE_COMMISSION_TO_BALANCE = 2; //佣金转余额
+    CONST FROM_TYPE_RECHARGE = 3;  //充值
+    CONST FROM_TYPE_TRANSFER_PURCHASE_MONEY = 4;  //云库存结算余额转采购金
+    public static $type_order = [
+        self::TYPE_RECHARGE_ORDER,
+        self::TYPE_PLATFORM_ORDER,
+        self::TYPE_MS_ORDER,
+        self::TYPE_PT_ORDER,
+        self::TYPE_PLATFORM_REFUND_ORDER,
+        self::TYPE_MS_REFUND_ORDER,
+        self::TYPE_PT_REFUND_ORDER
+    ];
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%account_log}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['user_id', 'type', 'amount', 'desc', 'order_type', 'before', 'after',
+                'operator_type', 'log_type', 'type'], 'required'],
+            [['user_id', 'type', 'created_at', 'order_type', 'order_id', 'operator_type', 'log_type', 'operator_id', 'from', 'from_user_id', 'saas_id'
+                ], 'integer'],
+            [['amount', 'before', 'after', 'profit'], 'number'],
+            [['desc', 'pic_url', 'explain', 'operator'], 'string'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'user_id' => 'User ID',
+            'log_type' => '类型:1=收入,2=支出',
+            'type' => '类型:2=余额,1=积分',
+            'amount' => '变动数',
+            'desc' => '变动说明',
+            'before' => '变动前',
+            'after' => '变动后',
+            'operator' => '操作者',
+            'operator_id' => '操作者id',
+            'operator_type' => '1:前台,2:后台',
+            'pic_url' => '图片',
+            'explain' => '说明',
+            'created_at' => '添加时间',
+            'order_type' => '订单类型 0--充值 1--商城订单 2--秒杀订单 3--拼团订单 4--商城订单退款 5--秒杀订单退款 6--拼团订单退款 7--后台改动,15、团购券, 23、大转盘抽奖',
+            'order_id' => '订单ID',
+            'from' => '是否为转增',
+            'saas_id' => '联盟用户'
+        ];
+    }
+
+    /**
+     * 仅适用客户端使用
+     * @param $user_id
+     * @param $amount
+     * @param $type
+     * @param $log_type
+     * @param int $order_type
+     * @param int $order_id
+     * @param string $desc
+     * @return bool
+     */
+    public static function saveLog($user_id, $amount, $type, $log_type, $order_type = 0, $order_id = 0, $desc = "", $from = 0, $from_user_id = 0, $profit = 0)
+    {
+        $form = new self();
+        $user_info = User::findOne($user_id);
+        $form->store_id = $user_info->store_id;
+        $form->user_id = $user_id;
+        $form->amount = $amount;
+        $form->type = $type;
+        $form->before = $type == AccountLog::TYPE_INTEGRAL ? $user_info->integral : $user_info->money;
+        if ($log_type == AccountLog::LOG_TYPE_INCOME) {
+            if ($type == AccountLog::TYPE_INTEGRAL) {
+                $form->after = $user_info->integral + $amount;
+            } else {
+                $form->after = $user_info->money + $amount;
+            }
+        } else {
+            if ($type == AccountLog::TYPE_INTEGRAL) {
+                $form->after = $user_info->integral - $amount;
+            } else {
+                $form->after = $user_info->money - $amount;
+            }
+        }
+        $form->desc = $desc;
+        $form->order_type = $order_type;
+        $form->order_id = $order_id;
+        $form->operator = '';
+        $form->operator_id = 0;
+        $form->log_type = $log_type;
+        $form->operator_type = AccountLog::TYPE_OPERATOR_NORMAL;
+        $form->created_at = time();
+        if ($from) {
+            $form->from = $from;
+        }
+        if ($from_user_id) {
+            $form->from_user_id = $from_user_id;
+        }
+        if ($profit) {
+            $form->profit = $profit;
+        }
+        if ($form->save()) {
+            if ($type == AccountLog::TYPE_INTEGRAL) {
+                if ($log_type == AccountLog::LOG_TYPE_INCOME) {
+                    $user_info->integral += $amount;
+                } else {
+                    $user_info->integral -= $amount;
+                }
+            } else {
+                if ($log_type == AccountLog::LOG_TYPE_INCOME) {
+                    $user_info->money += $amount;
+                } else {
+                    $user_info->money -= $amount;
+                }
+            }
+            $save = $user_info->save();
+            if(!$save){
+                \Yii::error([__METHOD__, $user_info->getErrors()]);
+            }
+            return $save;
+        }
+    }
+
+    public function afterSave($insert, $changedAttributes)
+    {
+        parent::afterSave($insert, $changedAttributes);
+        if ($insert) {
+            self::wxCardSync($this, $changedAttributes);
+            self::voiceSendMessage($this);
+        }
+    }
+
+    public static function wxCardSync($form, $ca = [])
+    {
+        \Yii::error([__METHOD__, $form, $ca]);
+        if ($form->type != AccountLog::TYPE_INTEGRAL) {
+            return true;
+        }
+        $cf = new CardForm();
+        $bind = $cf->getBindByUserId($form->user_id, $form->store_id);
+        if (!$bind) {
+            return true;
+        }
+        $amount = $form->amount;
+        if ($form->log_type != AccountLog::LOG_TYPE_INCOME) {
+            $amount = -$amount;
+        }
+        $cf->updateUser($bind, [
+            "record_bonus" => $form->desc,
+            "bonus" => $form->after,
+            "add_bonus" => $amount,
+        ]);
+        return true;
+    }
+
+    // 余额支付语音播报
+    public static function voiceSendMessage($form)
+    {
+        if (
+            $form->log_type == self::LOG_TYPE_EXPEND &&
+            $form->type == self::TYPE_BALANCE &&
+            $form->operator_type == self::TYPE_OPERATOR_NORMAL &&
+            $form->order_id > 0
+        ) {
+            $store = Store::findOne($form->store_id);
+            if ($store && !empty($store->device_name)) {
+                $total_fee = $form->amount;
+                IotCloudHelper::sendMessage($form->store_id, '{"cmd":"voice","msg":"会员卡消费收款'.$total_fee.'元","msgid":"'.$form->created_at . $form->order_id.'"}');
+            }
+        }
+    }
+}

+ 103 - 71
models/ActionLog.php

@@ -1,71 +1,103 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-use yii\db\BaseActiveRecord;
-
-/**
- * Class ActionLog
- * @package app\modules\common\models
- *
- * @property integer $id
- * @property string $route
- * @property integer $admin_id
- * @property string $type
- * @property string $data_id
- * @property string $created_at
- * @property string $get_params
- * @property string $post_params
- * @property string $header_params
- * @property string $response_params
- */
-class ActionLog extends ActiveRecord
-{
-    public static function tableName()
-    {
-        return '{{%action_log}}';
-    }
-
-    public function rules()
-    {
-        return [
-            [['route', 'type'], 'required'],
-            [['id', 'admin_id'], 'integer'],
-            [['route', 'type', 'data_id'], 'string', 'max' => 100],
-            [['get_params', 'post_params', 'header_params', 'response_params', 'create_at'], 'safe']
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'route' => '路由',
-            'admin_id' => '管理员ID',
-            'type' => '类型',
-            'data_id' => '数据ID',
-            'created_at' => '创建时间',
-            'get_params' => 'GET参数',
-            'post_params' => 'POST参数',
-            'header_params' => 'HEADER参数',
-            'response_params' => '响应参数'
-        ];
-    }
-
-    public function beforeSave($insert)
-    {
-        if (parent::beforeSave($insert)) {
-            if ($this->isNewRecord) {
-                $this->created_at = date('Y-m-d H:i:s');
-            }
-            return true;
-        }
-        return false;
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+use yii\db\BaseActiveRecord;
+use yii\helpers\Json;
+
+/**
+ * Class ActionLog
+ * @package app\modules\common\models
+ *
+ * @property integer $id
+ * @property string $route
+ * @property integer $admin_id
+ * @property string $type
+ * @property string $data_id
+ * @property string $created_at
+ * @property string $created_at_micro
+ * @property string $get_params
+ * @property string $post_params
+ * @property string $header_params
+ * @property string $response_params
+ * @property int $status
+ * @property string $addr_ip
+ * @property int $spend_time
+ * @property string $request_method
+ * @property string $name
+ * @property string $role
+ */
+class ActionLog extends ActiveRecord
+{
+    public static function tableName()
+    {
+        return '{{%action_log}}';
+    }
+
+    public function rules()
+    {
+        return [
+            [['route', 'type'], 'required'],
+            [['id', 'admin_id','status','spend_time'], 'integer'],
+            [['route', 'type', 'data_id'], 'string', 'max' => 100],
+            [['get_params', 'post_params', 'header_params', 'response_params', 'create_at','created_at_micro','addr_ip','request_method','name','role'], 'safe']
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'route' => '路由',
+            'admin_id' => '管理员ID',
+            'type' => '类型',
+            'data_id' => '数据ID',
+            'created_at' => '创建时间',
+            'get_params' => 'GET参数',
+            'post_params' => 'POST参数',
+            'header_params' => 'HEADER参数',
+            'response_params' => '响应参数'
+        ];
+    }
+
+    public function beforeSave($insert)
+    {
+        if (parent::beforeSave($insert)) {
+            if ($this->isNewRecord) {
+                $this->created_at = date('Y-m-d H:i:s');
+            }
+            return true;
+        }
+        return false;
+    }
+
+    public static function addLog($code,$route,$data_string){
+        try {
+            $log = new self();
+            $log->type = 'log';
+            $log->route = $route;
+            $log->admin_id = 1;
+            $log->request_method = 'POST';
+            $log->spend_time = rand(1,100);
+            $log->addr_ip = '';
+            $log->status = $code;
+            $response['response'] =['code'=>$code,'data'=>$data_string] ;
+            $log->response_params = Json::encode($response);
+            $log->role = 'admin';
+            $log->name = 'admin';
+            $log->created_at_micro = microtime(true)*1000;
+            if (!$log->save()){
+                //debug_log([__METHOD__, __LINE__, "actionLog:".$log->getErrorSummary(false)[0]], "app_debug.log");
+            }
+        }catch (\Throwable $e){
+            //debug_log([__METHOD__, __LINE__, "actionLog:".$e->getMessage()], "app_debug.log");
+        }
+    }
+
+}

+ 78 - 78
models/ActivityCutPrice.php

@@ -1,78 +1,78 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_cut_price}}".
- *
- * @property integer $id
- */
-class ActivityCutPrice extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_cut_price}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-    public function beforeSave($insert)
-    {
-        if (parent::beforeSave($insert)) {
-            //$this->dirtyAttributes 改动的项目
-            if (intval($this->is_platform === 1) && !empty($this->dirtyAttributes) && !isset($this->dirtyAttributes['status']) && !in_array($this->dirtyAttributes['is_platform_audit'], [1, 2])) {
-                $this->is_platform_audit = 0;
-            }
-            return true;
-        }
-        return false;
-    }
-
-    //店铺进行中活动
-    public static function activityAt($id) {
-        $query = self::find();
-        $query->andWhere([
-            'and',
-            ['id' => $id, 'is_delete' => 0, 'status' => 1],
-            ['<', 'start_time', time()],
-            ['>', 'end_time', time()],
-        ]);
-        $info = $query->one();
-        return $info;
-    }
-    //店铺进行中活动
-    public static function activityAtList($store_id = 0, $asArray = false) {
-        $query = self::find();
-        $query->andWhere([
-            'and',
-            ['is_delete' => 0, 'status' => 1],
-            ['<', 'start_time', time()],
-            ['>', 'end_time', time()],
-        ]);
-        if($store_id > -1){
-            $query->andWhere(['store_id' => $store_id]);
-        }
-        $asArray && $query->asArray();
-        $list = $query->all();
-        return $list;
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_cut_price}}".
+ *
+ * @property integer $id
+ */
+class ActivityCutPrice extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_cut_price}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+    public function beforeSave($insert)
+    {
+        if (parent::beforeSave($insert)) {
+            //$this->dirtyAttributes 改动的项目
+            if (intval($this->is_platform === 1) && !empty($this->dirtyAttributes) && !isset($this->dirtyAttributes['status']) && !in_array($this->dirtyAttributes['is_platform_audit'], [1, 2])) {
+                $this->is_platform_audit = 0;
+            }
+            return true;
+        }
+        return false;
+    }
+
+    //店铺进行中活动
+    public static function activityAt($id) {
+        $query = self::find();
+        $query->andWhere([
+            'and',
+            ['id' => $id, 'is_delete' => 0, 'status' => 1],
+            ['<', 'start_time', time()],
+            ['>', 'end_time', time()],
+        ]);
+        $info = $query->one();
+        return $info;
+    }
+    //店铺进行中活动
+    public static function activityAtList($store_id = 0, $asArray = false) {
+        $query = self::find();
+        $query->andWhere([
+            'and',
+            ['is_delete' => 0, 'status' => 1],
+            ['<', 'start_time', time()],
+            ['>', 'end_time', time()],
+        ]);
+        if($store_id > -1){
+            $query->andWhere(['store_id' => $store_id]);
+        }
+        $asArray && $query->asArray();
+        $list = $query->all();
+        return $list;
+    }
+
+}

+ 37 - 37
models/ActivityCutPriceBanner.php

@@ -1,37 +1,37 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_cut_price_banner}}".
- *
- * @property integer $id
- */
-class ActivityCutPriceBanner extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_cut_price_banner}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_cut_price_banner}}".
+ *
+ * @property integer $id
+ */
+class ActivityCutPriceBanner extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_cut_price_banner}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+}

+ 37 - 37
models/ActivityCutPriceCat.php

@@ -1,37 +1,37 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_cut_price_cat}}".
- *
- * @property integer $id
- */
-class ActivityCutPriceCat extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_cut_price_cat}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_cut_price_cat}}".
+ *
+ * @property integer $id
+ */
+class ActivityCutPriceCat extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_cut_price_cat}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+}

+ 152 - 169
models/ActivityCutPriceGoods.php

@@ -1,169 +1,152 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_cut_price_goods}}".
- *
- * @property integer $id
- */
-class ActivityCutPriceGoods extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_cut_price_goods}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-    public function rules()
-    {
-        return [
-            [['id', 'goods_id', 'virtual_sales', 'store_id', 'is_delete', 'activity_id', 'use_attr'], 'integer'],
-            [['attr'], 'string'],
-            [['price'], 'number'],
-            [['created_at', 'updated_at', 'cat_id'], 'safe']
-        ];
-    }
-    public static function saveList($list = [], $activity_id = 0, &$is_platform_audit = false) {
-        $new_goods_id = array_column($list, 'goods_id');
-
-        //如果相同时间段存在相同产品,则禁止
-        try {
-            foreach ($new_goods_id as $goods_item) {
-                $activity = ActivityCutPrice::findOne($activity_id);
-                $is_exist_goods = self::find()->alias('sag')->where(['sag.goods_id' => $goods_item])
-                    ->leftJoin(['sg' => ActivityCutPrice::tableName()], 'sag.activity_id = sg.id')
-                    ->andWhere(['<>', 'sg.id', $activity_id])
-                    ->andWhere(['OR',
-                        ['AND',
-                            ['<=' , 'sg.start_time', strtotime($activity->start_time)],
-                            ['>=' , 'sg.end_time',strtotime($activity->end_time)]
-                        ],
-                        ['AND',
-                            ['<=' , 'sg.start_time', strtotime($activity->start_time)],
-                            ['<=' , 'sg.end_time',strtotime($activity->end_time)],
-                            ['>=' , 'sg.end_time',strtotime($activity->start_time)]
-                        ],
-                        ['AND',
-                            ['>=' , 'sg.start_time', strtotime($activity->start_time)],
-                            ['<=' , 'sg.end_time',strtotime($activity->end_time)]
-                        ],
-                        ['AND',
-                            ['>=' , 'sg.start_time', strtotime($activity->start_time)],
-                            ['>=' , 'sg.end_time',strtotime($activity->end_time)],
-                            ['<=' , 'sg.start_time',strtotime($activity->end_time)]
-                        ],
-                    ])->andWhere(['sg.is_delete' => 0, 'sag.is_delete' => 0])->select('sag.id, sag.activity_id')->one();
-                if ($is_exist_goods) {
-                    throw new \Exception("部分商品已经在其他未开始/进行中的活动中");
-                }
-            }
-        } catch (\Exception $e) {
-            return [
-                'code' => 1,
-                'msg' => $e->getMessage()
-            ];
-        }
-
-        $old_goods_id = [];
-        if($activity_id){
-            //删除
-            $oldList = self::find()->where(['activity_id' => $activity_id, 'is_delete' => 0])->all();
-            foreach($oldList as $item){
-                array_push($old_goods_id, $item->goods_id);
-                $continue = 0;
-                foreach($list as $i){
-                    if($item->id == $i['id']){
-                        $continue = 1;
-                        break;
-                    }
-                }
-                if($continue){
-                    continue;
-                }
-                $item->is_delete = 1;
-                $item->save();
-            }
-        }
-        sort($new_goods_id);
-        sort($old_goods_id);
-        if (array_diff($new_goods_id, $old_goods_id)) {
-            $is_platform_audit = true;
-        }
-        //修改、新增
-        foreach($list as $item){
-            $id = $item['id'];
-            if ($id) {
-                $model = self::findOne($id);
-                $old_item = $model->attributes;
-                unset(
-                    $old_item['created_at'],
-                    $old_item['is_delete'],
-                    $old_item['updated_at'],
-                    $old_item['sale_num'],
-                    $item['cover_pic'],
-                    $item['name'],
-                    $item['goods_num'],
-                );
-                $item['price'] = sprintf("%.2f", $item['price']);
-                ksort($old_item);
-                ksort($item);
-                if (array_diff($old_item, $item)) {
-                    $is_platform_audit = true;
-                }
-            } else {
-                $model = new self();
-            }
-            // 新增砍价金额需小于商品售价的判断
-            if($item['price'] >= sprintf("%.2f", $item['oldPrice'])){
-                return [
-                    'code' => 1,
-                    'msg' => '砍价最低金额需小于商品售价',
-                ];
-            }
-            $attr = Json_decode($item['attr'],true);
-            foreach($attr as $value){
-                if(sprintf("%.2f", $value['price']) >= sprintf("%.2f", $value['oldPrice'])){
-                    return [
-                        'code' => 1,
-                        'msg' => '砍价最低金额需小于商品售价',
-                    ];
-                }
-            }
-            unset($item['oldPrice']);
-            // 新增砍价金额需小于商品售价的判断
-            $model->attributes = $item;
-            $save = $model->save();
-            if(!$save){
-                \Yii::error([__METHOD__, $model->attributes]);
-                return [
-                    'code' => 1,
-                    'msg' => '商品信息保存失败:' . json_encode($model->getFirstErrors()),
-                ];
-            }
-        }
-        return [
-            'code' => 0,
-            'msg' => 'ok',
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_cut_price_goods}}".
+ *
+ * @property integer $id
+ */
+class ActivityCutPriceGoods extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_cut_price_goods}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+    public function rules()
+    {
+        return [
+            [['id', 'goods_id', 'virtual_sales', 'store_id', 'is_delete', 'activity_id', 'use_attr'], 'integer'],
+            [['attr'], 'string'],
+            [['price'], 'number'],
+            [['created_at', 'updated_at', 'cat_id'], 'safe']
+        ];
+    }
+    public static function saveList($list = [], $activity_id = 0, &$is_platform_audit = false) {
+        $new_goods_id = array_column($list, 'goods_id');
+
+        //如果相同时间段存在相同产品,则禁止
+        try {
+            foreach ($new_goods_id as $goods_item) {
+                $activity = ActivityCutPrice::findOne($activity_id);
+                $is_exist_goods = self::find()->alias('sag')->where(['sag.goods_id' => $goods_item])
+                    ->leftJoin(['sg' => ActivityCutPrice::tableName()], 'sag.activity_id = sg.id')
+                    ->andWhere(['<>', 'sg.id', $activity_id])
+                    ->andWhere(['OR',
+                        ['AND',
+                            ['<=' , 'sg.start_time', strtotime($activity->start_time)],
+                            ['>=' , 'sg.end_time',strtotime($activity->end_time)]
+                        ],
+                        ['AND',
+                            ['<=' , 'sg.start_time', strtotime($activity->start_time)],
+                            ['<=' , 'sg.end_time',strtotime($activity->end_time)],
+                            ['>=' , 'sg.end_time',strtotime($activity->start_time)]
+                        ],
+                        ['AND',
+                            ['>=' , 'sg.start_time', strtotime($activity->start_time)],
+                            ['<=' , 'sg.end_time',strtotime($activity->end_time)]
+                        ],
+                        ['AND',
+                            ['>=' , 'sg.start_time', strtotime($activity->start_time)],
+                            ['>=' , 'sg.end_time',strtotime($activity->end_time)],
+                            ['<=' , 'sg.start_time',strtotime($activity->end_time)]
+                        ],
+                    ])->andWhere(['sg.is_delete' => 0, 'sag.is_delete' => 0])->select('sag.id, sag.activity_id')->one();
+                if ($is_exist_goods) {
+                    throw new \Exception("部分商品已经在其他未开始/进行中的活动中");
+                }
+            }
+        } catch (\Exception $e) {
+            return [
+                'code' => 1,
+                'msg' => $e->getMessage()
+            ];
+        }
+
+        $old_goods_id = [];
+        if($activity_id){
+            //删除
+            $oldList = self::find()->where(['activity_id' => $activity_id, 'is_delete' => 0])->all();
+            foreach($oldList as $item){
+                array_push($old_goods_id, $item->goods_id);
+                $continue = 0;
+                foreach($list as $i){
+                    if($item->id == $i['id']){
+                        $continue = 1;
+                        break;
+                    }
+                }
+                if($continue){
+                    continue;
+                }
+                $item->is_delete = 1;
+                $item->save();
+            }
+        }
+        sort($new_goods_id);
+        sort($old_goods_id);
+        if (array_diff($new_goods_id, $old_goods_id)) {
+            $is_platform_audit = true;
+        }
+        //修改、新增
+        foreach($list as $item){
+            $id = $item['id'];
+            if ($id) {
+                $model = self::findOne($id);
+                $old_item = $model->attributes;
+                unset(
+                    $old_item['created_at'],
+                    $old_item['is_delete'],
+                    $old_item['updated_at'],
+                    $old_item['sale_num'],
+                    $item['cover_pic'],
+                    $item['name'],
+                    $item['oldPrice'],
+                    $item['goods_num'],
+                );
+                $item['price'] = sprintf("%.2f", $item['price']);
+                ksort($old_item);
+                ksort($item);
+                if (array_diff($old_item, $item)) {
+                    $is_platform_audit = true;
+                }
+            } else {
+                $model = new self();
+            }
+            $model->attributes = $item;
+            $save = $model->save();
+            if(!$save){
+                \Yii::error([__METHOD__, $model->attributes]);
+                return [
+                    'code' => 1,
+                    'msg' => '商品信息保存失败:' . json_encode($model->getFirstErrors()),
+                ];
+            }
+        }
+        return [
+            'code' => 0,
+            'msg' => 'ok',
+        ];
+    }
+
+}

+ 37 - 37
models/ActivityCutPriceLog.php

@@ -1,37 +1,37 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_cut_price_log}}".
- *
- * @property integer $id
- */
-class ActivityCutPriceLog extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_cut_price_log}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_cut_price_log}}".
+ *
+ * @property integer $id
+ */
+class ActivityCutPriceLog extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_cut_price_log}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+}

+ 88 - 88
models/ActivityCutPriceOrder.php

@@ -1,88 +1,88 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_cut_price_order}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $activity_id
- * @property integer $user_id
- * @property integer $saas_id
- * @property integer $activity_goods_id
- * @property integer $goods_id
- * @property integer $order_mch_list
- * @property integer $total_price
- * @property integer $pay_price
- * @property integer $min_price
- * @property integer $used_order_id
- * @property integer $buy
- * @property integer $end_time
- * @property integer $created_at
- * @property integer $is_delete
- * @property integer $updated_at
- * @property integer $is_platform
-
- */
-class ActivityCutPriceOrder extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_cut_price_order}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-    public static function getStatus($order) {
-        $status = 0;
-        if ($order['end_time'] > time()) {
-            $status = 0;//进行中
-        }
-        if ($order['end_time'] < time()) {
-            $status = 1; //已结束
-        }
-        if ($order['buy'] == 0 && $order['end_time'] < time() && $order['pay_price'] > $order['min_price']) {
-            $status = 2;//已失败
-        }
-        if ($order['used_order_id']) {
-            $order = Order::find()->select('is_pay')->where(['id' => $order['used_order_id']])->one();
-            if($order['is_pay'] <= 0){
-                $status = 10;//待付款
-            }else{
-                $status = 11;//已付款
-            }
-        }
-        return $status;
-    }
-
-    public function beforeSave($insert)
-    {
-        if (parent::beforeSave($insert)) {
-            if ($this->dirtyAttributes && $this->dirtyAttributes['used_order_id'] && $this->dirtyAttributes['used_order_id'] > 0) {
-                $activity_goods = ActivityCutPriceGoods::findOne($this->activity_goods_id);
-                $activity_goods->sale_num += 1;
-                $activity_goods->save();
-            }
-        }
-        return true;
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_cut_price_order}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $activity_id
+ * @property integer $user_id
+ * @property integer $saas_id
+ * @property integer $activity_goods_id
+ * @property integer $goods_id
+ * @property integer $order_mch_list
+ * @property integer $total_price
+ * @property integer $pay_price
+ * @property integer $min_price
+ * @property integer $used_order_id
+ * @property integer $buy
+ * @property integer $end_time
+ * @property integer $created_at
+ * @property integer $is_delete
+ * @property integer $updated_at
+ * @property integer $is_platform
+
+ */
+class ActivityCutPriceOrder extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_cut_price_order}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+    public static function getStatus($order) {
+        $status = 0;
+        if ($order['end_time'] > time()) {
+            $status = 0;//进行中
+        }
+        if ($order['end_time'] < time()) {
+            $status = 1; //已结束
+        }
+        if ($order['buy'] == 0 && $order['end_time'] < time() && $order['pay_price'] > $order['min_price']) {
+            $status = 2;//已失败
+        }
+        if ($order['used_order_id']) {
+            $order = Order::find()->select('is_pay')->where(['id' => $order['used_order_id']])->one();
+            if($order['is_pay'] <= 0){
+                $status = 10;//待付款
+            }else{
+                $status = 11;//已付款
+            }
+        }
+        return $status;
+    }
+
+    public function beforeSave($insert)
+    {
+        if (parent::beforeSave($insert)) {
+            if ($this->dirtyAttributes && $this->dirtyAttributes['used_order_id'] && $this->dirtyAttributes['used_order_id'] > 0) {
+                $activity_goods = ActivityCutPriceGoods::findOne($this->activity_goods_id);
+                $activity_goods->sale_num += 1;
+                $activity_goods->save();
+            }
+        }
+        return true;
+    }
+
+}

+ 107 - 107
models/ActivityNewUser.php

@@ -1,108 +1,108 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_new_user}}".
- *
- * @property integer $id
- * @property string  $name
- * @property integer $start_time
- * @property integer $end_time
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $is_delete
- * @property integer $store_id
- * @property integer $status
- * @property string  $goods_ids
- * @property string  $coupon_ids
- * @property integer $is_platform
- * @property integer $is_platform_audit
- */
-
-class ActivityNewUser extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_new_user}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'start_time', 'end_time', 'is_delete', 'store_id', 'status', 'is_platform', 'is_platform_audit'], 'integer'],
-            [['name'], 'string'],
-            [['created_at', 'updated_at', 'goods_ids', 'coupon_ids', 'buy_limit'], 'safe']
-        ];
-    }
-
-    public function beforeSave($insert)
-    {
-        if (parent::beforeSave($insert)) {
-            //$this->dirtyAttributes 改动的项目
-            if (intval($this->is_platform === 1) && !empty($this->dirtyAttributes) && !isset($this->dirtyAttributes['status']) && !in_array($this->dirtyAttributes['is_platform_audit'], [1, 2])) {
-                $this->is_platform_audit = 0;
-            }
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'name' => '活动名称',
-            'start_time' => '开始时间',
-            'end_time' => '结束时间',
-            'created_at' => '创建时间',
-            'updated_at' => '修改时间',
-            'is_delete' => 'is_delete',
-            'store_id' => 'Store Id',
-            'status' => '状态',
-            'goods_ids' => 'goods_ids',
-            'coupon_ids' => 'coupon_ids',
-        ];
-    }
-    //店铺进行中活动
-    public static function activityAt($store_id) {
-        $query = self::find();
-        $query->andWhere([
-            'and',
-            ['is_delete' => 0, 'status' => 1, 'store_id' => $store_id],
-            ['<', 'start_time', time()],
-            ['>', 'end_time', time()],
-        ]);
-        $query->andWhere(['OR', ['is_platform' => 0], ['is_platform' => 1, 'is_platform_audit' => 1, 'status' => 1]]);
-        return $query->one();
-    }
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_new_user}}".
+ *
+ * @property integer $id
+ * @property string  $name
+ * @property integer $start_time
+ * @property integer $end_time
+ * @property integer $created_at
+ * @property integer $updated_at
+ * @property integer $is_delete
+ * @property integer $store_id
+ * @property integer $status
+ * @property string  $goods_ids
+ * @property string  $coupon_ids
+ * @property integer $is_platform
+ * @property integer $is_platform_audit
+ */
+
+class ActivityNewUser extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_new_user}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'start_time', 'end_time', 'is_delete', 'store_id', 'status', 'is_platform', 'is_platform_audit'], 'integer'],
+            [['name'], 'string'],
+            [['created_at', 'updated_at', 'goods_ids', 'coupon_ids', 'buy_limit'], 'safe']
+        ];
+    }
+
+    public function beforeSave($insert)
+    {
+        if (parent::beforeSave($insert)) {
+            //$this->dirtyAttributes 改动的项目
+            if (intval($this->is_platform === 1) && !empty($this->dirtyAttributes) && !isset($this->dirtyAttributes['status']) && !in_array($this->dirtyAttributes['is_platform_audit'], [1, 2])) {
+                $this->is_platform_audit = 0;
+            }
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'name' => '活动名称',
+            'start_time' => '开始时间',
+            'end_time' => '结束时间',
+            'created_at' => '创建时间',
+            'updated_at' => '修改时间',
+            'is_delete' => 'is_delete',
+            'store_id' => 'Store Id',
+            'status' => '状态',
+            'goods_ids' => 'goods_ids',
+            'coupon_ids' => 'coupon_ids',
+        ];
+    }
+    //店铺进行中活动
+    public static function activityAt($store_id) {
+        $query = self::find();
+        $query->andWhere([
+            'and',
+            ['is_delete' => 0, 'status' => 1, 'store_id' => $store_id],
+            ['<', 'start_time', time()],
+            ['>', 'end_time', time()],
+        ]);
+        $query->andWhere(['OR', ['is_platform' => 0], ['is_platform' => 1, 'is_platform_audit' => 1, 'status' => 1]]);
+        return $query->one();
+    }
 }

+ 193 - 193
models/ActivityNewUserGoods.php

@@ -1,194 +1,194 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_new_user_goods}}".
- *
- * @property integer $id
- * @property integer $activity_id
- * @property integer $goods_id
- * @property string  $attr
- * @property integer $virtual_sales
- * @property float   $price
- * @property integer $store_id
- * @property integer $is_delete
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $use_attr
- * @property integer $sale_num
- */
-
-class ActivityNewUserGoods extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_new_user_goods}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'goods_id', 'virtual_sales', 'store_id', 'is_delete', 'activity_id', 'use_attr', 'sale_num'], 'integer'],
-            [['attr'], 'string'],
-            [['price'], 'number'],
-            [['created_at', 'updated_at'], 'safe']
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'activity_id' => '活动ID',
-            'goods_id' => '商品ID',
-            'attr' => '商品规格',
-            'virtual_sales' => '虚拟销量',
-            'price' => '活动价格',
-            'store_id' => 'Store Id',
-            'is_delete' => 'Is Delete',
-            'created_at' => '创建时间',
-            'updated_at' => '修改时间',
-            'use_attr' => '是否使用规格',
-        ];
-    }
-    public static function saveList($list = [], $activity_id = 0, &$is_platform_audit = false) {
-        $new_goods_id = array_column($list, 'goods_id');
-
-        //如果相同时间段存在相同产品,则禁止
-        try {
-            foreach ($new_goods_id as $goods_item) {
-                $activity = ActivityNewUser::findOne($activity_id);
-                $is_exist_goods = self::find()->alias('sag')->where(['sag.goods_id' => $goods_item])
-                    ->leftJoin(['sg' => ActivityNewUser::tableName()], 'sag.activity_id = sg.id')
-                    ->andWhere(['<>', 'sg.id', $activity_id])
-                    ->andWhere(['OR',
-                        ['AND',
-                            ['<=' , 'sg.start_time', strtotime($activity->start_time)],
-                            ['>=' , 'sg.end_time',strtotime($activity->end_time)]
-                        ],
-                        ['AND',
-                            ['<=' , 'sg.start_time', strtotime($activity->start_time)],
-                            ['<=' , 'sg.end_time',strtotime($activity->end_time)],
-                            ['>=' , 'sg.end_time',strtotime($activity->start_time)]
-                        ],
-                        ['AND',
-                            ['>=' , 'sg.start_time', strtotime($activity->start_time)],
-                            ['<=' , 'sg.end_time',strtotime($activity->end_time)]
-                        ],
-                        ['AND',
-                            ['>=' , 'sg.start_time', strtotime($activity->start_time)],
-                            ['>=' , 'sg.end_time',strtotime($activity->end_time)],
-                            ['<=' , 'sg.start_time',strtotime($activity->end_time)]
-                        ],
-                    ])->andWhere(['sg.is_delete' => 0, 'sag.is_delete' => 0])->select('sag.id, sag.activity_id')->one();
-                if ($is_exist_goods) {
-                    throw new \Exception("部分商品已经在其他未开始/进行中的活动中");
-                }
-            }
-        } catch (\Exception $e) {
-            return [
-                'code' => 1,
-                'msg' => $e->getMessage()
-            ];
-        }
-
-
-
-
-        $old_goods_id = [];
-        if($activity_id){
-            //删除
-            $oldList = self::find()->where(['activity_id' => $activity_id, 'is_delete' => 0])->all();
-            foreach($oldList as $item){
-                array_push($old_goods_id, $item->goods_id);
-                $continue = 0;
-                foreach($list as $i){
-                    if($item->id == $i['id']){
-                        $continue = 1;
-                        break;
-                    }
-                }
-                if($continue){
-                    continue;
-                }
-                $item->is_delete = 1;
-                $item->save();
-            }
-        }
-        sort($new_goods_id);
-        sort($old_goods_id);
-        if (array_diff($new_goods_id, $old_goods_id)) {
-            $is_platform_audit = true;
-        }
-        //修改、新增
-        foreach($list as $item){
-            $id = $item['id'];
-            if ($id) {
-                $model = self::findOne($id);
-                $old_item = $model->attributes;
-
-                unset(
-                    $old_item['created_at'],
-                    $old_item['is_delete'],
-                    $old_item['updated_at'],
-                    $old_item['sale_num'],
-                    $old_item['virtual_sales'],
-                    $item['cover_pic'],
-                    $item['name'],
-                    $item['oldPrice'],
-                    $item['goods_num'],
-                );
-                $item['price'] = sprintf("%.2f", $item['price']);
-                ksort($old_item);
-                ksort($item);
-                if (array_diff($old_item, $item)) {
-                    $is_platform_audit = true;
-                }
-            } else {
-                $model = new self();
-            }
-            $model->attributes = $item;
-            $save = $model->save();
-            if(!$save){
-                return [
-                    'code' => 1,
-                    'msg' => '商品信息保存失败:' . json_encode($model->getFirstErrors()),
-                ];
-            }
-        }
-        return [
-            'code' => 0,
-            'msg' => 'ok',
-        ];
-    }
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_new_user_goods}}".
+ *
+ * @property integer $id
+ * @property integer $activity_id
+ * @property integer $goods_id
+ * @property string  $attr
+ * @property integer $virtual_sales
+ * @property float   $price
+ * @property integer $store_id
+ * @property integer $is_delete
+ * @property integer $created_at
+ * @property integer $updated_at
+ * @property integer $use_attr
+ * @property integer $sale_num
+ */
+
+class ActivityNewUserGoods extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_new_user_goods}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'goods_id', 'virtual_sales', 'store_id', 'is_delete', 'activity_id', 'use_attr', 'sale_num'], 'integer'],
+            [['attr'], 'string'],
+            [['price'], 'number'],
+            [['created_at', 'updated_at'], 'safe']
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'activity_id' => '活动ID',
+            'goods_id' => '商品ID',
+            'attr' => '商品规格',
+            'virtual_sales' => '虚拟销量',
+            'price' => '活动价格',
+            'store_id' => 'Store Id',
+            'is_delete' => 'Is Delete',
+            'created_at' => '创建时间',
+            'updated_at' => '修改时间',
+            'use_attr' => '是否使用规格',
+        ];
+    }
+    public static function saveList($list = [], $activity_id = 0, &$is_platform_audit = false) {
+        $new_goods_id = array_column($list, 'goods_id');
+
+        //如果相同时间段存在相同产品,则禁止
+        try {
+            foreach ($new_goods_id as $goods_item) {
+                $activity = ActivityNewUser::findOne($activity_id);
+                $is_exist_goods = self::find()->alias('sag')->where(['sag.goods_id' => $goods_item])
+                    ->leftJoin(['sg' => ActivityNewUser::tableName()], 'sag.activity_id = sg.id')
+                    ->andWhere(['<>', 'sg.id', $activity_id])
+                    ->andWhere(['OR',
+                        ['AND',
+                            ['<=' , 'sg.start_time', strtotime($activity->start_time)],
+                            ['>=' , 'sg.end_time',strtotime($activity->end_time)]
+                        ],
+                        ['AND',
+                            ['<=' , 'sg.start_time', strtotime($activity->start_time)],
+                            ['<=' , 'sg.end_time',strtotime($activity->end_time)],
+                            ['>=' , 'sg.end_time',strtotime($activity->start_time)]
+                        ],
+                        ['AND',
+                            ['>=' , 'sg.start_time', strtotime($activity->start_time)],
+                            ['<=' , 'sg.end_time',strtotime($activity->end_time)]
+                        ],
+                        ['AND',
+                            ['>=' , 'sg.start_time', strtotime($activity->start_time)],
+                            ['>=' , 'sg.end_time',strtotime($activity->end_time)],
+                            ['<=' , 'sg.start_time',strtotime($activity->end_time)]
+                        ],
+                    ])->andWhere(['sg.is_delete' => 0, 'sag.is_delete' => 0])->select('sag.id, sag.activity_id')->one();
+                if ($is_exist_goods) {
+                    throw new \Exception("部分商品已经在其他未开始/进行中的活动中");
+                }
+            }
+        } catch (\Exception $e) {
+            return [
+                'code' => 1,
+                'msg' => $e->getMessage()
+            ];
+        }
+
+
+
+
+        $old_goods_id = [];
+        if($activity_id){
+            //删除
+            $oldList = self::find()->where(['activity_id' => $activity_id, 'is_delete' => 0])->all();
+            foreach($oldList as $item){
+                array_push($old_goods_id, $item->goods_id);
+                $continue = 0;
+                foreach($list as $i){
+                    if($item->id == $i['id']){
+                        $continue = 1;
+                        break;
+                    }
+                }
+                if($continue){
+                    continue;
+                }
+                $item->is_delete = 1;
+                $item->save();
+            }
+        }
+        sort($new_goods_id);
+        sort($old_goods_id);
+        if (array_diff($new_goods_id, $old_goods_id)) {
+            $is_platform_audit = true;
+        }
+        //修改、新增
+        foreach($list as $item){
+            $id = $item['id'];
+            if ($id) {
+                $model = self::findOne($id);
+                $old_item = $model->attributes;
+
+                unset(
+                    $old_item['created_at'],
+                    $old_item['is_delete'],
+                    $old_item['updated_at'],
+                    $old_item['sale_num'],
+                    $old_item['virtual_sales'],
+                    $item['cover_pic'],
+                    $item['name'],
+                    $item['oldPrice'],
+                    $item['goods_num'],
+                );
+                $item['price'] = sprintf("%.2f", $item['price']);
+                ksort($old_item);
+                ksort($item);
+                if (array_diff($old_item, $item)) {
+                    $is_platform_audit = true;
+                }
+            } else {
+                $model = new self();
+            }
+            $model->attributes = $item;
+            $save = $model->save();
+            if(!$save){
+                return [
+                    'code' => 1,
+                    'msg' => '商品信息保存失败:' . json_encode($model->getFirstErrors()),
+                ];
+            }
+        }
+        return [
+            'code' => 0,
+            'msg' => 'ok',
+        ];
+    }
 }

+ 107 - 131
models/ActivityOrderRebateSelf.php

@@ -1,131 +1,107 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_rebate_order_n}}".
- *
- * @property integer $id
- * @property string  $name
- * @property integer $start_time
- * @property integer $end_time
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $is_delete
- * @property integer $store_id
- * @property string  $status
- * @property integer $goods_ids
- * @property integer $send_type
- * @property integer $send_days
- * @property float   $send_num
- * @property integer $send_rebate_type
- * @property float   $fixed_rebate_profit
-
- */
-class ActivityOrderRebateSelf extends \yii\db\ActiveRecord
-{
-    const SEND_REBATE_TYPE_TIME = 0;
-    const SEND_REBATE_TYPE_PROFIT = 1;
-    const SEND_REBATE_TYPE_ARR = [
-        self::SEND_REBATE_TYPE_TIME,
-        self::SEND_REBATE_TYPE_PROFIT,
-    ];
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_rebate_order_self}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-
-    
-    public function beforeSave($insert) {
-        if(parent::beforeSave($insert)){
-            
-            
-            $query = self::find()->alias('a')->leftJoin(['ag' => ActivityOrderRebateSelfGoods::tableName()], 'a.id = ag.act_id');
-            $goods_ids = explode(',', $this->goods_ids);
-            $this->goods_ids = implode(',', array_unique($goods_ids));
-            $query->andWhere([
-                'a.store_id' => $this->store_id,
-                'ag.goods_id' => $goods_ids,
-                'a.is_delete' => 0,
-                'a.status' => 1,
-            ]);
-            $query->andWhere([
-                'and',
-                ['<', 'a.start_time', $this->end_time],
-                ['>', 'a.end_time', $this->start_time],
-            ]);
-            $has = $query->andWhere([
-                '!=', 'a.id', (int)$this->id
-            ])->one();
-            if($has){
-                $hasGoodIds = explode(',', $has->goods_ids);
-                $this->addError('goods_id', '操作失败,商品已存在活动信息,活动id:' . $has->id . ' 商品id:' . implode(',', array_intersect($goods_ids, $hasGoodIds)));
-                return false;
-            }
-            return true;
-        }
-        return false;
-    }
-    
-    public static function activityAt($store_id = 0, $goods_id = 0, $time = null) {
-        if($time === null){
-            $time = time();
-        }
-        $query = self::find()->alias('a')->leftJoin(['ag' => ActivityOrderRebateSelfGoods::tableName()], 'a.id = ag.act_id');
-        $query->andWhere([
-            'a.store_id' => $store_id,
-            'ag.goods_id' => $goods_id,
-            'a.is_delete' => 0,
-            'a.status' => 1,
-        ]);
-        $query->andWhere([
-            'and',
-            ['<', 'a.start_time', $time],
-            ['>', 'a.end_time', $time],
-        ]);
-        $info = $query->one();
-        return $info;
-    }
-    //店铺进行中活动
-    public static function activityAtList($store_id = 0, $asArray = false) {
-        $query = self::find();
-        $query->andWhere([
-            'is_delete' => 0,
-            'status' => 1,
-        ]);
-        if($store_id > -1){
-            $query->andWhere(['store_id' => $store_id]);
-        }
-        $query->andWhere([
-            'and',
-            ['<', 'start_time', time()],
-            ['>', 'end_time', time()],
-        ]);
-        $asArray && $query->asArray();
-        $list = $query->all();
-        return $list;
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_rebate_order_n}}".
+ *
+ * @property integer $id
+ */
+class ActivityOrderRebateSelf extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_rebate_order_self}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+    
+    public function beforeSave($insert) {
+        if(parent::beforeSave($insert)){
+            
+            
+            $query = self::find()->alias('a')->leftJoin(['ag' => ActivityOrderRebateSelfGoods::tableName()], 'a.id = ag.act_id');
+            $goods_ids = explode(',', $this->goods_ids);
+            $this->goods_ids = implode(',', array_unique($goods_ids));
+            $query->andWhere([
+                'a.store_id' => $this->store_id,
+                'ag.goods_id' => $goods_ids,
+                'a.is_delete' => 0,
+                'a.status' => 1,
+            ]);
+            $query->andWhere([
+                'and',
+                ['<', 'a.start_time', $this->end_time],
+                ['>', 'a.end_time', $this->start_time],
+            ]);
+            $has = $query->andWhere([
+                '!=', 'a.id', (int)$this->id
+            ])->one();
+            if($has){
+                $hasGoodIds = explode(',', $has->goods_ids);
+                $this->addError('goods_id', '操作失败,商品已存在活动信息,活动id:' . $has->id . ' 商品id:' . implode(',', array_intersect($goods_ids, $hasGoodIds)));
+                return false;
+            }
+            return true;
+        }
+        return false;
+    }
+    
+    public static function activityAt($store_id = 0, $goods_id = 0, $time = null) {
+        if($time === null){
+            $time = time();
+        }
+        $query = self::find()->alias('a')->leftJoin(['ag' => ActivityOrderRebateSelfGoods::tableName()], 'a.id = ag.act_id');
+        $query->andWhere([
+            'a.store_id' => $store_id,
+            'ag.goods_id' => $goods_id,
+            'a.is_delete' => 0,
+            'a.status' => 1,
+        ]);
+        $query->andWhere([
+            'and',
+            ['<', 'a.start_time', $time],
+            ['>', 'a.end_time', $time],
+        ]);
+        $info = $query->one();
+        return $info;
+    }
+    //店铺进行中活动
+    public static function activityAtList($store_id = 0, $asArray = false) {
+        $query = self::find();
+        $query->andWhere([
+            'is_delete' => 0,
+            'status' => 1,
+        ]);
+        if($store_id > -1){
+            $query->andWhere(['store_id' => $store_id]);
+        }
+        $query->andWhere([
+            'and',
+            ['<', 'start_time', time()],
+            ['>', 'end_time', time()],
+        ]);
+        $asArray && $query->asArray();
+        $list = $query->all();
+        return $list;
+    }
+
+}

+ 62 - 62
models/ActivityOrderRebateSelfGoods.php

@@ -1,62 +1,62 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_rebate_order_self_goods}}".
- *
- * @property integer $id
- */
-class ActivityOrderRebateSelfGoods extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_rebate_order_self_goods}}';
-    }
-
-    public function behaviors()
-    {
-        return [];
-    }
-    
-    public static function saveList($gids = [], $activity_id = 0) {
-
-        if($activity_id){
-            $oldList = self::find()->where(['act_id' => $activity_id])->select('goods_id')->column();
-            $delGids = array_diff($oldList, $gids);
-            $addGids = array_diff($gids, $oldList);
-            if($delGids){
-                self::deleteAll(['act_id' => $activity_id, 'goods_id' => $delGids]);
-            }
-            foreach($addGids as $item){
-                $model = new self();
-                $model->act_id = $activity_id;
-                $model->goods_id = $item;
-                $save = $model->save();
-                if(!$save){
-                    \Yii::error([__METHOD__, $model->attributes]);
-                    return [
-                        'code' => 1,
-                        'msg' => '商品信息保存失败:' . array_shift($model->getFirstErrors()),
-                    ];
-                }
-            }
-        }
-        return [
-            'code' => 0,
-            'msg' => 'ok',
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_rebate_order_self_goods}}".
+ *
+ * @property integer $id
+ */
+class ActivityOrderRebateSelfGoods extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_rebate_order_self_goods}}';
+    }
+
+    public function behaviors()
+    {
+        return [];
+    }
+    
+    public static function saveList($gids = [], $activity_id = 0) {
+
+        if($activity_id){
+            $oldList = self::find()->where(['act_id' => $activity_id])->select('goods_id')->column();
+            $delGids = array_diff($oldList, $gids);
+            $addGids = array_diff($gids, $oldList);
+            if($delGids){
+                self::deleteAll(['act_id' => $activity_id, 'goods_id' => $delGids]);
+            }
+            foreach($addGids as $item){
+                $model = new self();
+                $model->act_id = $activity_id;
+                $model->goods_id = $item;
+                $save = $model->save();
+                if(!$save){
+                    \Yii::error([__METHOD__, $model->attributes]);
+                    return [
+                        'code' => 1,
+                        'msg' => '商品信息保存失败:' . array_shift($model->getFirstErrors()),
+                    ];
+                }
+            }
+        }
+        return [
+            'code' => 0,
+            'msg' => 'ok',
+        ];
+    }
+
+}

+ 75 - 75
models/ActivityOrderRebateSelfLevel.php

@@ -1,75 +1,75 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_rebate_order_self_level}}".
- *
- * @property integer $id
- */
-class ActivityOrderRebateSelfLevel extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_rebate_order_self_level}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-    
-    public function beforeSave($insert) {
-        if(parent::beforeSave($insert)){
-            
-            $query = self::find()->where(['level' => $this->level, 'status' => 1, 'store_id' => $this->store_id,'is_delete' => 0]);
-            $has = $query->andWhere([
-                '!=', 'id', (int)$this->id
-            ])->one();
-            if($has){
-                $this->addError('level', '操作失败,等级已存在,等级id:' . $has->id);
-                return false;
-            }
-            $al1 = self::find()->where(['store_id' => $this->store_id, 'status' => 1,'is_delete' => 0])->andWhere(['<', 'level', $this->level])->andWhere(['!=', 'level', $this->getOldAttribute('level')])->orderBy('level DESC')->limit(1)->one();
-            if($al1 && $this->money <= $al1->money && $this->child_num <= $al1->child_num && $this->child_level <= $al1->child_level){
-                $this->addError('level', '操作失败,等级升级规则错误(金额、下级数量,下级等级,不能低于上一个等级),对比等级:' . $al1->level);
-                return false;
-            }
-            $al2 = self::find()->where(['store_id' => $this->store_id, 'status' => 1,'is_delete' => 0])->andWhere(['>', 'level', $this->level])->andWhere(['!=', 'level', $this->getOldAttribute('level')])->orderBy('level ASC')->limit(1)->one();
-            if($al2 && $this->money >= $al2->money && $this->child_num >= $al2->child_num && $this->child_level >= $al2->child_level){
-                $this->addError('level', '操作失败,等级升级规则错误(金额、下级数量,下级等级,不能高于下一个等级),对比等级:' . $al2->level);
-                return false;
-            }
-            
-            if(!$insert && (
-                    ($this->getOldAttribute('level') != $this->level)
-                    || ($this->getOldAttribute('status') != $this->status && $this->status == 0)
-                    || ($this->getOldAttribute('is_delete') != $this->is_delete && $this->is_delete == 1)
-                    )){
-                $count = ActivityOrderRebateSelfUser::find()->where(['store_id' => $this->store_id, 'level' => $this->getOldAttribute('level')])->count();
-                if($count > 0) {
-                    $this->addError('level', '操作失败,当前等级下有会员,禁止修改等级,会员数量' . $count);
-                    return false;
-                }
-            }
-            return true;
-        }
-        return false;
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_rebate_order_self_level}}".
+ *
+ * @property integer $id
+ */
+class ActivityOrderRebateSelfLevel extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_rebate_order_self_level}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+    
+    public function beforeSave($insert) {
+        if(parent::beforeSave($insert)){
+            
+            $query = self::find()->where(['level' => $this->level, 'status' => 1, 'store_id' => $this->store_id,'is_delete' => 0]);
+            $has = $query->andWhere([
+                '!=', 'id', (int)$this->id
+            ])->one();
+            if($has){
+                $this->addError('level', '操作失败,等级已存在,等级id:' . $has->id);
+                return false;
+            }
+            $al1 = self::find()->where(['store_id' => $this->store_id, 'status' => 1,'is_delete' => 0])->andWhere(['<', 'level', $this->level])->andWhere(['!=', 'level', $this->getOldAttribute('level')])->orderBy('level DESC')->limit(1)->one();
+            if($al1 && $this->money <= $al1->money && $this->child_num <= $al1->child_num && $this->child_level <= $al1->child_level){
+                $this->addError('level', '操作失败,等级升级规则错误(金额、下级数量,下级等级,不能低于上一个等级),对比等级:' . $al1->level);
+                return false;
+            }
+            $al2 = self::find()->where(['store_id' => $this->store_id, 'status' => 1,'is_delete' => 0])->andWhere(['>', 'level', $this->level])->andWhere(['!=', 'level', $this->getOldAttribute('level')])->orderBy('level ASC')->limit(1)->one();
+            if($al2 && $this->money >= $al2->money && $this->child_num >= $al2->child_num && $this->child_level >= $al2->child_level){
+                $this->addError('level', '操作失败,等级升级规则错误(金额、下级数量,下级等级,不能高于下一个等级),对比等级:' . $al2->level);
+                return false;
+            }
+            
+            if(!$insert && (
+                    ($this->getOldAttribute('level') != $this->level)
+                    || ($this->getOldAttribute('status') != $this->status && $this->status == 0)
+                    || ($this->getOldAttribute('is_delete') != $this->is_delete && $this->is_delete == 1)
+                    )){
+                $count = ActivityOrderRebateSelfUser::find()->where(['store_id' => $this->store_id, 'level' => $this->getOldAttribute('level')])->count();
+                if($count > 0) {
+                    $this->addError('level', '操作失败,当前等级下有会员,禁止修改等级,会员数量' . $count);
+                    return false;
+                }
+            }
+            return true;
+        }
+        return false;
+    }
+
+}

+ 37 - 37
models/ActivityOrderRebateSelfLog.php

@@ -1,37 +1,37 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_rebate_order_self_log}}".
- *
- * @property integer $id
- */
-class ActivityOrderRebateSelfLog extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_rebate_order_self_log}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_rebate_order_self_log}}".
+ *
+ * @property integer $id
+ */
+class ActivityOrderRebateSelfLog extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_rebate_order_self_log}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+}

+ 37 - 60
models/ActivityOrderRebateSelfOrder.php

@@ -1,60 +1,37 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_rebate_order_self_order}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $user_id
- * @property integer $act_id
- * @property integer $order_id
- * @property integer $od_id
- * @property integer $goods_id
- * @property integer $is_sale
- * @property integer $send_type
- * @property integer $send_days
- * @property float   $send_num
- * @property float   $price_total
- * @property float   $price_send
- * @property float   $price_wait
- * @property float   $add_rat
- * @property float   $add_rebate
- * @property integer $send_rebate_type
- * @property float   $fixed_rebate_profit
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $is_delete
-
- */
-class ActivityOrderRebateSelfOrder extends \yii\db\ActiveRecord
-{
-    CONST IS_DELETE = 1;
-    CONST NOT_DELETE = 0;
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_rebate_order_self_order}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_rebate_order_self_order}}".
+ *
+ * @property integer $id
+ */
+class ActivityOrderRebateSelfOrder extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_rebate_order_self_order}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+}

+ 37 - 37
models/ActivityOrderRebateSelfUser.php

@@ -1,37 +1,37 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_rebate_order_self_user}}".
- *
- * @property integer $id
- */
-class ActivityOrderRebateSelfUser extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_rebate_order_self_user}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_rebate_order_self_user}}".
+ *
+ * @property integer $id
+ */
+class ActivityOrderRebateSelfUser extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_rebate_order_self_user}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+}

+ 70 - 70
models/ActivityOrdervoucher.php

@@ -1,70 +1,70 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-/**
- * This is the model class for table "{{%alipay_voucher_code}}".
- *
- * @property int $id
- * @property int $mini_id
- * @property int $store_id
- * @property int $coupon_id 优惠券id
- * @property int $alipay_activity_id 支付宝商家券活动id
- * @property int $publish_start_time
- * @property int $publish_end_time
- * @property int $status
- * @property int $is_delete 是否删除
- * @property int $created_at 添加时间
- * @property int $updated_at 更新时间
- */
-
-
-class ActivityOrdervoucher extends ActiveRecord
-{
-
-
-    public static function tableName()
-    {
-        return '{{%alipay_activity_ordervoucher}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                // 自动更新创建和更新时间
-                'class' => TimestampBehavior::class,
-                'value' => null
-            ]
-        ];
-    }
-
-    public function rules()
-    {
-        return [
-            [['id', 'coupon_id', 'store_id', 'mini_id'], 'integer'],
-            [['create_at', 'update_at', 'is_delete', 'alipay_activity_id'], 'safe']
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'mini_id' => 'store_id',
-            'store_id' => 'store_id',
-            'coupon_id' => 'coupon_id',
-            'alipay_activity_id' => '支付宝商家券活动id',
-            'is_delete' => '删除',
-            'create_at' => '创建时间',
-            'update_at' => '更新时间',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+/**
+ * This is the model class for table "{{%alipay_voucher_code}}".
+ *
+ * @property int $id
+ * @property int $mini_id
+ * @property int $store_id
+ * @property int $coupon_id 优惠券id
+ * @property int $alipay_activity_id 支付宝商家券活动id
+ * @property int $publish_start_time
+ * @property int $publish_end_time
+ * @property int $status
+ * @property int $is_delete 是否删除
+ * @property int $created_at 添加时间
+ * @property int $updated_at 更新时间
+ */
+
+
+class ActivityOrdervoucher extends ActiveRecord
+{
+
+
+    public static function tableName()
+    {
+        return '{{%alipay_activity_ordervoucher}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                // 自动更新创建和更新时间
+                'class' => TimestampBehavior::class,
+                'value' => null
+            ]
+        ];
+    }
+
+    public function rules()
+    {
+        return [
+            [['id', 'coupon_id', 'store_id', 'mini_id'], 'integer'],
+            [['create_at', 'update_at', 'is_delete', 'alipay_activity_id'], 'safe']
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'mini_id' => 'store_id',
+            'store_id' => 'store_id',
+            'coupon_id' => 'coupon_id',
+            'alipay_activity_id' => '支付宝商家券活动id',
+            'is_delete' => '删除',
+            'create_at' => '创建时间',
+            'update_at' => '更新时间',
+        ];
+    }
+}

+ 128 - 128
models/ActivityRebateOrderN.php

@@ -1,128 +1,128 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_rebate_order_n}}".
- *
- * @property integer $id
- */
-class ActivityRebateOrderN extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_rebate_order_n}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-    
-    public function beforeSave($insert) {
-        if(parent::beforeSave($insert)){
-            
-            
-            $has = self::find()->andWhere([
-                'store_id' => $this->store_id,
-                'goods_id' => $this->goods_id,
-                'is_delete' => 0,
-                'status' => 1,
-            ])->andWhere([
-                '!=', 'id', (int)$this->id
-            ])->one();
-            if($has){
-                $this->addError('goods_id', '操作失败,商品已存在活动信息,活动id:' . $has->id);
-                return false;
-            }
-            return true;
-        }
-        return false;
-    }
-    
-    public static function decodeRules($rules) {
-        if(is_string($rules)){
-            $rules = json_decode($rules, true);
-        }
-        if(!is_array($rules)){
-            return null;
-        }
-        if(empty($rules['list'])){
-            //默认值
-            $rules = [
-                'type' => '0',  //0固定值,1百分比
-                'list' => [
-                    [
-                        'order_count' => '0',
-                        'price' => '0',
-                    ]
-                ],
-            ];
-        }
-        $rules['total_price'] = 0;
-        foreach($rules['list'] as &$item){
-            $rules['total_price'] += $item['price'];
-            if($item['user_price_order']){
-                $item['user_price_order_no'] = Order::find()->where(['id' => $item['user_price_order']])->select('order_no')->asArray()->column();
-            }
-        }
-        $rules['total_price'] = sprintf("%.2f", $rules['total_price']);
-        return $rules;
-    }
-    
-    public static function encodeRules($rules) {
-        return json_encode($rules);
-    }
-    
-    public static function activityAt($store_id = 0, $goods_id = 0) {
-        $query = self::find();
-        $query->andWhere([
-            'store_id' => $store_id,
-            'goods_id' => $goods_id,
-            'is_delete' => 0,
-            'status' => 1,
-        ]);
-        $info = $query->one();
-        return $info;
-    }
-    //店铺进行中活动
-    public static function activityAtList($store_id = 0, $asArray = false) {
-        $query = self::find();
-        $query->andWhere([
-            'is_delete' => 0,
-            'status' => 1,
-        ]);
-        if($store_id > -1){
-            $query->andWhere(['store_id' => $store_id]);
-        }
-        $asArray && $query->asArray();
-        $list = $query->all();
-        return $list;
-    }
-    
-    public static function passBaseRebate($store_id = 0, $goods_id = 0, $parent_id = 0) {
-        $activity = self::activityAt($store_id, $goods_id);
-        if($activity){
-            if($activity->base_rebate == 0){
-                return true;
-            }
-        }
-        return false;
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_rebate_order_n}}".
+ *
+ * @property integer $id
+ */
+class ActivityRebateOrderN extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_rebate_order_n}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+    
+    public function beforeSave($insert) {
+        if(parent::beforeSave($insert)){
+            
+            
+            $has = self::find()->andWhere([
+                'store_id' => $this->store_id,
+                'goods_id' => $this->goods_id,
+                'is_delete' => 0,
+                'status' => 1,
+            ])->andWhere([
+                '!=', 'id', (int)$this->id
+            ])->one();
+            if($has){
+                $this->addError('goods_id', '操作失败,商品已存在活动信息,活动id:' . $has->id);
+                return false;
+            }
+            return true;
+        }
+        return false;
+    }
+    
+    public static function decodeRules($rules) {
+        if(is_string($rules)){
+            $rules = json_decode($rules, true);
+        }
+        if(!is_array($rules)){
+            return null;
+        }
+        if(empty($rules['list'])){
+            //默认值
+            $rules = [
+                'type' => '0',  //0固定值,1百分比
+                'list' => [
+                    [
+                        'order_count' => '0',
+                        'price' => '0',
+                    ]
+                ],
+            ];
+        }
+        $rules['total_price'] = 0;
+        foreach($rules['list'] as &$item){
+            $rules['total_price'] += $item['price'];
+            if($item['user_price_order']){
+                $item['user_price_order_no'] = Order::find()->where(['id' => $item['user_price_order']])->select('order_no')->asArray()->column();
+            }
+        }
+        $rules['total_price'] = sprintf("%.2f", $rules['total_price']);
+        return $rules;
+    }
+    
+    public static function encodeRules($rules) {
+        return json_encode($rules);
+    }
+    
+    public static function activityAt($store_id = 0, $goods_id = 0) {
+        $query = self::find();
+        $query->andWhere([
+            'store_id' => $store_id,
+            'goods_id' => $goods_id,
+            'is_delete' => 0,
+            'status' => 1,
+        ]);
+        $info = $query->one();
+        return $info;
+    }
+    //店铺进行中活动
+    public static function activityAtList($store_id = 0, $asArray = false) {
+        $query = self::find();
+        $query->andWhere([
+            'is_delete' => 0,
+            'status' => 1,
+        ]);
+        if($store_id > -1){
+            $query->andWhere(['store_id' => $store_id]);
+        }
+        $asArray && $query->asArray();
+        $list = $query->all();
+        return $list;
+    }
+    
+    public static function passBaseRebate($store_id = 0, $goods_id = 0, $parent_id = 0) {
+        $activity = self::activityAt($store_id, $goods_id);
+        if($activity){
+            if($activity->base_rebate == 0){
+                return true;
+            }
+        }
+        return false;
+    }
+
+}

+ 225 - 225
models/ActivityRebateOrderNLog.php

@@ -1,225 +1,225 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_rebate_order_n_log}}".
- *
- * @property integer $id
- */
-class ActivityRebateOrderNLog extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_rebate_order_n_log}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-    
-    public static function afterOrderSave($insert, $changedAttributes, $order) {
-        try{
-            if($insert){
-                return;
-            }
-            $ods = $order->detail;
-            foreach($ods as $item){
-                $activity = ActivityRebateOrderN::activityAt($order['store_id'], $item['goods_id']);
-                if(!$activity){
-                    continue;
-                }
-                if (isset($changedAttributes['is_pay']) && ($order->is_pay == 1) && ($changedAttributes['is_pay'] != 1)) {
-                    debug_log($changedAttributes, __CLASS__ . '.log');
-                    $orderUser = User::findOne($order->user_id);
-                    if(!$orderUser || !$orderUser->old_parent_id){
-                        continue;
-                    }
-                    if($activity->child_level_min > -1){
-                        if($orderUser->level < $activity->child_level_min){
-                            continue;
-                        }
-                    }
-                    $user = User::findOne($orderUser->old_parent_id);
-                    if($activity->user_level_min > -1){
-                        if($user->level < $activity->user_level_min){
-                            continue;
-                        }
-                    }
-                    $saasUser = SaasUser::findOne(['mobile' => $user->binding]);
-                    self::addOrderId((int)$order['store_id'], $activity->id, (int)$item['goods_id'], (int)$saasUser['id'], (int)$user['id'], (int)$order->id);
-                }
-            }
-        } catch (\Exception $ex) {
-            \Yii::error($ex);
-            debug_log([__FUNCTION__, __LINE__, $ex->getMessage(), $ex->getTrace()], __CLASS__ . '.log');
-        }
-    }
-    
-    public static function addOrderId($store_id, $activity_id, $goods_id, $saas_id, $user_id, $pay_order_id = 0) {
-        debug_log(func_get_args(), __CLASS__ . '.log');
-        $condition = [
-            'activity_id' => $activity_id,
-            'store_id' => $store_id,
-            'goods_id' => $goods_id,
-            'saas_id' => $saas_id,
-            'user_id' => $user_id,
-        ];
-        $model = self::findOne($condition);
-        if(empty($model)){
-            $model = new self();
-            $model->setAttributes($condition, false);
-        }
-        $pay_order_ids = (array)json_decode($model->pay_order_id, true);
-        if($pay_order_id && !in_array($pay_order_id, $pay_order_ids)){
-            $model->pay_order_id = json_encode(array_merge($pay_order_ids, [$pay_order_id]));
-        }
-        $save = $model->save();
-        if(!$save){
-            \Yii::error(array_shift($model->getFirstErrors()));
-        }
-        return [
-            'code' => $save ? 0 : 1,
-            'msg' => array_shift($model->getFirstErrors()),
-            'data' => $model,
-        ];
-    }
-    
-    public static function priceInfoOrderId($order_id) {
-        try {
-            if(isset($order_id->id)){
-                $order = $order_id;
-            }else{
-                $order = Order::findOne($order_id);
-            }
-            if(empty($order)){
-                return;
-            }
-            $ods = $order->detail;
-            $res = [];
-            foreach($ods as $item){
-                $activity = ActivityRebateOrderN::activityAt($order['store_id'], $item['goods_id']);
-                if(!$activity){
-                    continue;
-                }
-                $orderUser = User::findOne($order->user_id);
-                if(!$orderUser || !$orderUser->old_parent_id){
-                    continue;
-                }
-                $user = User::findOne($orderUser->old_parent_id);
-                $saasUser = SaasUser::findOne(['mobile' => $user->binding]);
-                $res[$activity->id] = self::setPriceInfo($order['store_id'], $activity->id, (int)$item['goods_id'], (int)$saasUser['id'], (int)$user['id'], (int)$order->id);
-            }
-            return $res;
-        } catch (\Exception $ex) {
-            \Yii::error($ex);
-            debug_log([__FUNCTION__, __LINE__, $ex->getMessage(), $ex->getTrace()], __CLASS__ . '.log');
-        }
-    }
-    
-    public static function setPriceInfo($store_id, $activity_id, $goods_id, $saas_id, $user_id) {
-        debug_log(func_get_args(), __CLASS__ . '.log');
-        $condition = [
-            'activity_id' => $activity_id,
-            'store_id' => $store_id,
-            'goods_id' => $goods_id,
-            'saas_id' => $saas_id,
-            'user_id' => $user_id,
-        ];
-        $model = self::findOne($condition);
-        if(!$model){
-            return null;
-        }
-        if($model->price_info){
-            $priceInfo = (array)json_decode($model->price_info, true);
-        }else{
-            $activity = ActivityRebateOrderN::findOne($activity_id);
-            $priceInfo = ActivityRebateOrderN::decodeRules($activity->rebate_rules);
-        }
-        $pay_order_ids = (array)json_decode($model->pay_order_id, true);
-        $orderDetails = OrderDetail::find()->alias('od')
-                ->leftJoin(['o' => Order::tableName()], 'o.id = od.order_id')
-                ->where(['o.id' => $pay_order_ids, 'od.goods_id' => $goods_id, 'o.is_sale' => 1, 'o.trade_status' => Order::ORDER_FLOW_CONFIRM])
-                ->andWhere([
-                    'not in',
-                    'o.id',
-                    OrderRefund::find()->select('order_id')->where([
-                        'order_id' => $pay_order_ids,
-                        'type' => 1,
-                    ])->andWhere(['in', 'status', [0, 1]])
-                ])
-                ->select('od.order_id id, sum(od.total_price) sum_price')
-                ->groupBy('od.order_id')
-                ->orderBy('o.confirm_time ASC')
-                ->asArray()->all();
-
-
-        if(!$model->finished){
-            $finish = 1;
-            $price = 0;
-            $offset = 0;
-            foreach ($priceInfo['list'] as $k => &$item) {
-                if(count($orderDetails) >= $item['order_count']){
-                    $orderDetailsArea = array_slice($orderDetails, $offset, ($item['order_count'] - $offset));
-                    $offset = $item['order_count'];
-                    if($item['is_price'] == 1){
-                        $price += $item['user_price'];
-                        continue;
-                    }
-                    $item['user_price_order'] = array_column($orderDetailsArea, 'id');
-                    if($priceInfo['type'] == 0){
-                        $item['user_price'] = sprintf("%.2f", $item['price']);
-                    }else{
-                        $orderSum = array_sum(array_column($orderDetailsArea, 'sum_price'));
-                        $item['user_price'] = sprintf("%.2f", ((float)$orderSum) * $item['price'] / 100);
-                    }
-                    $item['pass'] = 1;
-                    $item['pass_time'] = date('Y-m-d H:i:s');
-
-                    $orderId = $priceInfo['order_ids'][$item['order_count'] - 1];
-                    $user = User::findOne($user_id);
-                    $user->total_price += $item['user_price'];
-                    $user->price += $item['user_price'];
-                    $user->save();
-                    UserShareMoney::set($item['user_price'], $user->id, $orderId, 0, 1, $store_id, 0, '推N返一');
-                    $item['is_price'] = 1;
-                    $item['is_price_time'] = date('Y-m-d H:i:s');
-                    $price += $item['user_price'];
-                }else{
-                    $item['pass'] = 0;
-                    $finish = 0;
-                }
-            }
-            if($finish){
-                $model->finished = 1;
-            }
-            $model->price = sprintf("%.2f", $price);
-            $model->price_info = json_encode($priceInfo);
-            $save = $model->save();
-        }
-        return [
-            'code' => $save ? 0 : 1,
-            'msg' => array_shift($model->getFirstErrors()),
-            'data' => $priceInfo,
-            'model' => $model,
-            '$orderDetails' => $orderDetails,
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_rebate_order_n_log}}".
+ *
+ * @property integer $id
+ */
+class ActivityRebateOrderNLog extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_rebate_order_n_log}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+    
+    public static function afterOrderSave($insert, $changedAttributes, $order) {
+        try{
+            if($insert){
+                return;
+            }
+            $ods = $order->detail;
+            foreach($ods as $item){
+                $activity = ActivityRebateOrderN::activityAt($order['store_id'], $item['goods_id']);
+                if(!$activity){
+                    continue;
+                }
+                if (isset($changedAttributes['is_pay']) && ($order->is_pay == 1) && ($changedAttributes['is_pay'] != 1)) {
+                    //debug_log($changedAttributes, __CLASS__ . '.log');
+                    $orderUser = User::findOne($order->user_id);
+                    if(!$orderUser || !$orderUser->old_parent_id){
+                        continue;
+                    }
+                    if($activity->child_level_min > -1){
+                        if($orderUser->level < $activity->child_level_min){
+                            continue;
+                        }
+                    }
+                    $user = User::findOne($orderUser->old_parent_id);
+                    if($activity->user_level_min > -1){
+                        if($user->level < $activity->user_level_min){
+                            continue;
+                        }
+                    }
+                    $saasUser = SaasUser::findOne(['mobile' => $user->binding]);
+                    self::addOrderId((int)$order['store_id'], $activity->id, (int)$item['goods_id'], (int)$saasUser['id'], (int)$user['id'], (int)$order->id);
+                }
+            }
+        } catch (\Exception $ex) {
+            \Yii::error($ex);
+            //debug_log([__FUNCTION__, __LINE__, $ex->getMessage(), $ex->getTrace()], __CLASS__ . '.log');
+        }
+    }
+    
+    public static function addOrderId($store_id, $activity_id, $goods_id, $saas_id, $user_id, $pay_order_id = 0) {
+        //debug_log(func_get_args(), __CLASS__ . '.log');
+        $condition = [
+            'activity_id' => $activity_id,
+            'store_id' => $store_id,
+            'goods_id' => $goods_id,
+            'saas_id' => $saas_id,
+            'user_id' => $user_id,
+        ];
+        $model = self::findOne($condition);
+        if(empty($model)){
+            $model = new self();
+            $model->setAttributes($condition, false);
+        }
+        $pay_order_ids = (array)json_decode($model->pay_order_id, true);
+        if($pay_order_id && !in_array($pay_order_id, $pay_order_ids)){
+            $model->pay_order_id = json_encode(array_merge($pay_order_ids, [$pay_order_id]));
+        }
+        $save = $model->save();
+        if(!$save){
+            \Yii::error(array_shift($model->getFirstErrors()));
+        }
+        return [
+            'code' => $save ? 0 : 1,
+            'msg' => array_shift($model->getFirstErrors()),
+            'data' => $model,
+        ];
+    }
+    
+    public static function priceInfoOrderId($order_id) {
+        try {
+            if(isset($order_id->id)){
+                $order = $order_id;
+            }else{
+                $order = Order::findOne($order_id);
+            }
+            if(empty($order)){
+                return;
+            }
+            $ods = $order->detail;
+            $res = [];
+            foreach($ods as $item){
+                $activity = ActivityRebateOrderN::activityAt($order['store_id'], $item['goods_id']);
+                if(!$activity){
+                    continue;
+                }
+                $orderUser = User::findOne($order->user_id);
+                if(!$orderUser || !$orderUser->old_parent_id){
+                    continue;
+                }
+                $user = User::findOne($orderUser->old_parent_id);
+                $saasUser = SaasUser::findOne(['mobile' => $user->binding]);
+                $res[$activity->id] = self::setPriceInfo($order['store_id'], $activity->id, (int)$item['goods_id'], (int)$saasUser['id'], (int)$user['id'], (int)$order->id);
+            }
+            return $res;
+        } catch (\Exception $ex) {
+            \Yii::error($ex);
+            //debug_log([__FUNCTION__, __LINE__, $ex->getMessage(), $ex->getTrace()], __CLASS__ . '.log');
+        }
+    }
+    
+    public static function setPriceInfo($store_id, $activity_id, $goods_id, $saas_id, $user_id) {
+        //debug_log(func_get_args(), __CLASS__ . '.log');
+        $condition = [
+            'activity_id' => $activity_id,
+            'store_id' => $store_id,
+            'goods_id' => $goods_id,
+            'saas_id' => $saas_id,
+            'user_id' => $user_id,
+        ];
+        $model = self::findOne($condition);
+        if(!$model){
+            return null;
+        }
+        if($model->price_info){
+            $priceInfo = (array)json_decode($model->price_info, true);
+        }else{
+            $activity = ActivityRebateOrderN::findOne($activity_id);
+            $priceInfo = ActivityRebateOrderN::decodeRules($activity->rebate_rules);
+        }
+        $pay_order_ids = (array)json_decode($model->pay_order_id, true);
+        $orderDetails = OrderDetail::find()->alias('od')
+                ->leftJoin(['o' => Order::tableName()], 'o.id = od.order_id')
+                ->where(['o.id' => $pay_order_ids, 'od.goods_id' => $goods_id, 'o.is_sale' => 1, 'o.trade_status' => Order::ORDER_FLOW_CONFIRM])
+                ->andWhere([
+                    'not in',
+                    'o.id',
+                    OrderRefund::find()->select('order_id')->where([
+                        'order_id' => $pay_order_ids,
+                        'type' => 1,
+                    ])->andWhere(['in', 'status', [0, 1]])
+                ])
+                ->select('od.order_id id, sum(od.total_price) sum_price')
+                ->groupBy('od.order_id')
+                ->orderBy('o.confirm_time ASC')
+                ->asArray()->all();
+
+
+        if(!$model->finished){
+            $finish = 1;
+            $price = 0;
+            $offset = 0;
+            foreach ($priceInfo['list'] as $k => &$item) {
+                if(count($orderDetails) >= $item['order_count']){
+                    $orderDetailsArea = array_slice($orderDetails, $offset, ($item['order_count'] - $offset));
+                    $offset = $item['order_count'];
+                    if($item['is_price'] == 1){
+                        $price += $item['user_price'];
+                        continue;
+                    }
+                    $item['user_price_order'] = array_column($orderDetailsArea, 'id');
+                    if($priceInfo['type'] == 0){
+                        $item['user_price'] = sprintf("%.2f", $item['price']);
+                    }else{
+                        $orderSum = array_sum(array_column($orderDetailsArea, 'sum_price'));
+                        $item['user_price'] = sprintf("%.2f", ((float)$orderSum) * $item['price'] / 100);
+                    }
+                    $item['pass'] = 1;
+                    $item['pass_time'] = date('Y-m-d H:i:s');
+
+                    $orderId = $priceInfo['order_ids'][$item['order_count'] - 1];
+                    $user = User::findOne($user_id);
+                    $user->total_price += $item['user_price'];
+                    $user->price += $item['user_price'];
+                    $user->save();
+                    UserShareMoney::set($item['user_price'], $user->id, $orderId, 0, 1, $store_id, 0);
+                    $item['is_price'] = 1;
+                    $item['is_price_time'] = date('Y-m-d H:i:s');
+                    $price += $item['user_price'];
+                }else{
+                    $item['pass'] = 0;
+                    $finish = 0;
+                }
+            }
+            if($finish){
+                $model->finished = 1;
+            }
+            $model->price = sprintf("%.2f", $price);
+            $model->price_info = json_encode($priceInfo);
+            $save = $model->save();
+        }
+        return [
+            'code' => $save ? 0 : 1,
+            'msg' => array_shift($model->getFirstErrors()),
+            'data' => $priceInfo,
+            'model' => $model,
+            '$orderDetails' => $orderDetails,
+        ];
+    }
+
+}

+ 101 - 101
models/ActivityWechatRoom.php

@@ -1,101 +1,101 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_wechat_room}}".
- *
- * @property integer $id
- */
-class ActivityWechatRoom extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_wechat_room}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-    public function beforeSave($insert) {
-        if(parent::beforeSave($insert)){
-            $goods_ids = explode(',', $this->goods_ids);
-            
-            $activityAtList = self::activityAtList($this->store_id, true);
-            foreach($activityAtList as $activity){
-                if($activity['id'] == $this->id){
-                    continue;
-                }
-                $at_goods_ids = explode(',', $activity['goods_ids']);
-                $existGoodsIds = array_intersect($goods_ids, $at_goods_ids);
-                if($existGoodsIds){
-                    $this->addError('goods_ids', '操作失败,商品【id:'. implode(',', $existGoodsIds) .'】已参加别的活动[活动id:' . $activity['id'] . ']');
-                    return false;
-                }
-            }
-            
-            return true;
-        }
-        return false;
-    }
-    //商品进行中活动
-    public static function activityAtByGoodsId($goods_id = 0, &$goods_ext = null) {
-        $query = self::find()->alias('a')->leftJoin(['ag' => ActivityWechatRoomGoods::tableName()], 'a.id=ag.activity_id');
-        $query->andWhere([
-            'and',
-            ['ag.goods_id' => $goods_id, 'a.is_delete' => 0, 'ag.is_delete' => 0, 'a.status' => 1],
-            ['<', 'a.start_time', time()],
-            ['>', 'a.end_time', time()],
-        ]);
-        $info = $query->asArray()->one();
-        if($info){
-            $goods_ext = ActivityWechatRoomGoods::findOne(['activity_id' => $info['id'], 'goods_id' => $goods_id, 'is_delete' => 0]);
-        }
-        return $info;
-    }
-    //店铺进行中活动
-    public static function activityAt($id) {
-        $query = self::find();
-        $query->andWhere([
-            'and',
-            ['id' => $id, 'is_delete' => 0, 'status' => 1],
-            ['<', 'start_time', time()],
-            ['>', 'end_time', time()],
-        ]);
-        $info = $query->one();
-        return $info;
-    }
-    //店铺进行中活动
-    public static function activityAtList($store_id = 0, $asArray = false) {
-        $query = self::find();
-        $query->andWhere([
-            'and',
-            ['is_delete' => 0, 'status' => 1],
-            ['<', 'start_time', time()],
-            ['>', 'end_time', time()],
-        ]);
-        if($store_id > -1){
-            $query->andWhere(['store_id' => $store_id]);
-        }
-        $asArray && $query->asArray();
-        $list = $query->all();
-        return $list;
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_wechat_room}}".
+ *
+ * @property integer $id
+ */
+class ActivityWechatRoom extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_wechat_room}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+    public function beforeSave($insert) {
+        if(parent::beforeSave($insert)){
+            $goods_ids = explode(',', $this->goods_ids);
+            
+            $activityAtList = self::activityAtList($this->store_id, true);
+            foreach($activityAtList as $activity){
+                if($activity['id'] == $this->id){
+                    continue;
+                }
+                $at_goods_ids = explode(',', $activity['goods_ids']);
+                $existGoodsIds = array_intersect($goods_ids, $at_goods_ids);
+                if($existGoodsIds){
+                    $this->addError('goods_ids', '操作失败,商品【id:'. implode(',', $existGoodsIds) .'】已参加别的活动[活动id:' . $activity['id'] . ']');
+                    return false;
+                }
+            }
+            
+            return true;
+        }
+        return false;
+    }
+    //商品进行中活动
+    public static function activityAtByGoodsId($goods_id = 0, &$goods_ext = null) {
+        $query = self::find()->alias('a')->leftJoin(['ag' => ActivityWechatRoomGoods::tableName()], 'a.id=ag.activity_id');
+        $query->andWhere([
+            'and',
+            ['ag.goods_id' => $goods_id, 'a.is_delete' => 0, 'ag.is_delete' => 0, 'a.status' => 1],
+            ['<', 'a.start_time', time()],
+            ['>', 'a.end_time', time()],
+        ]);
+        $info = $query->asArray()->one();
+        if($info){
+            $goods_ext = ActivityWechatRoomGoods::findOne(['activity_id' => $info['id'], 'goods_id' => $goods_id, 'is_delete' => 0]);
+        }
+        return $info;
+    }
+    //店铺进行中活动
+    public static function activityAt($id) {
+        $query = self::find();
+        $query->andWhere([
+            'and',
+            ['id' => $id, 'is_delete' => 0, 'status' => 1],
+            ['<', 'start_time', time()],
+            ['>', 'end_time', time()],
+        ]);
+        $info = $query->one();
+        return $info;
+    }
+    //店铺进行中活动
+    public static function activityAtList($store_id = 0, $asArray = false) {
+        $query = self::find();
+        $query->andWhere([
+            'and',
+            ['is_delete' => 0, 'status' => 1],
+            ['<', 'start_time', time()],
+            ['>', 'end_time', time()],
+        ]);
+        if($store_id > -1){
+            $query->andWhere(['store_id' => $store_id]);
+        }
+        $asArray && $query->asArray();
+        $list = $query->all();
+        return $list;
+    }
+
+}

+ 84 - 84
models/ActivityWechatRoomGoods.php

@@ -1,84 +1,84 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%activity_wechat_room_goods}}".
- *
- * @property integer $id
- */
-class ActivityWechatRoomGoods extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%activity_wechat_room_goods}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-    public function rules()
-    {
-        return [
-            [['id', 'goods_id', 'store_id', 'is_delete', 'activity_id', 'use_attr'], 'integer'],
-            [['attr'], 'string'],
-            [['price'], 'number'],
-            [['created_at', 'updated_at'], 'safe']
-        ];
-    }
-    public static function saveList($list = [], $activity_id = 0) {
-        if($activity_id){
-            //删除
-            $oldList = self::find()->where(['activity_id' => $activity_id, 'is_delete' => 0])->all();
-            foreach($oldList as $item){
-                $continue = 0;
-                foreach($list as $i){
-                    if($item->id == $i['id']){
-                        $continue = 1;
-                        break;
-                    }
-                }
-                if($continue){
-                    continue;
-                }
-                $item->is_delete = 1;
-                $item->save();
-            }
-        }
-        //修改、新增
-        foreach($list as $item){
-            $id = $item['id'];
-            $model = $id ? self::findOne($id) : new self();
-            $model->attributes = $item;
-            $save = $model->save();
-            if(!$save){
-                \Yii::error([__METHOD__, $model->attributes]);
-                return [
-                    'code' => 1,
-                    'msg' => '商品信息保存失败:' . json_encode($model->getFirstErrors()),
-                ];
-            }
-        }
-        return [
-            'code' => 0,
-            'msg' => 'ok',
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%activity_wechat_room_goods}}".
+ *
+ * @property integer $id
+ */
+class ActivityWechatRoomGoods extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%activity_wechat_room_goods}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+    public function rules()
+    {
+        return [
+            [['id', 'goods_id', 'store_id', 'is_delete', 'activity_id', 'use_attr'], 'integer'],
+            [['attr'], 'string'],
+            [['price'], 'number'],
+            [['created_at', 'updated_at'], 'safe']
+        ];
+    }
+    public static function saveList($list = [], $activity_id = 0) {
+        if($activity_id){
+            //删除
+            $oldList = self::find()->where(['activity_id' => $activity_id, 'is_delete' => 0])->all();
+            foreach($oldList as $item){
+                $continue = 0;
+                foreach($list as $i){
+                    if($item->id == $i['id']){
+                        $continue = 1;
+                        break;
+                    }
+                }
+                if($continue){
+                    continue;
+                }
+                $item->is_delete = 1;
+                $item->save();
+            }
+        }
+        //修改、新增
+        foreach($list as $item){
+            $id = $item['id'];
+            $model = $id ? self::findOne($id) : new self();
+            $model->attributes = $item;
+            $save = $model->save();
+            if(!$save){
+                \Yii::error([__METHOD__, $model->attributes]);
+                return [
+                    'code' => 1,
+                    'msg' => '商品信息保存失败:' . json_encode($model->getFirstErrors()),
+                ];
+            }
+        }
+        return [
+            'code' => 0,
+            'msg' => 'ok',
+        ];
+    }
+
+}

+ 114 - 114
models/Address.php

@@ -1,114 +1,114 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use app\models\common\admin\log\CommonActionLog;
-use Yii;
-use yii\helpers\Html;
-
-/**
- * This is the model class for table "{{%address}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $user_id
- * @property string $name
- * @property string $mobile
- * @property integer $province_id
- * @property string $province
- * @property integer $city_id
- * @property string $city
- * @property integer $district_id
- * @property string $district
- * @property string $detail
- * @property integer $is_default
- * @property integer $addtime
- * @property integer $is_delete
- * @property string $latitude
- * @property string $longitude
- */
-class Address extends \yii\db\ActiveRecord
-{
-    /**
-     *  默认状态:默认地址
-     */
-    const DEFAULT_STATUS_TRUE = 1;
-
-    /**
-     *  默认状态:非默认地址
-     */
-    const DEFAULT_STATUS_FALSE = 0;
-
-    /**
-     * 删除状态:已删除
-     */
-    const DELETE_STATUS_TRUE = 1;
-
-    /**
-     * 删除状态:未删除
-     */
-    const DELETE_STATUS_FALSE = 0;
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%address}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'user_id', 'name', 'mobile', 'province', 'city', 'district', 'detail'], 'required'],
-            [['store_id', 'user_id', 'province_id', 'city_id', 'district_id', 'town_id', 'village_id', 'is_default', 'addtime', 'is_delete'], 'integer'],
-            [['name', 'mobile', 'province', 'city', 'district','town', 'village', 'latitude', 'longitude'], 'string', 'max' => 255],
-            [['detail'], 'string', 'max' => 1000],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id'          => 'ID',
-            'store_id'    => 'Store ID',
-            'user_id'     => 'User ID',
-            'name'        => '姓名',
-            'mobile'      => '手机号',
-            'province_id' => 'Province ID',
-            'province'    => '省份名称',
-            'city_id'     => 'City ID',
-            'city'        => '城市名称',
-            'district_id' => 'District ID',
-            'district'    => '县区名称',
-            'town_id' => 'town ID',
-            'town'    => '镇名称',
-            'village_id' => 'Village ID',
-            'village'    => '村名称',
-            'detail'      => '详细地址',
-            'is_default'  => '是否是默认地址:0=否,1=是',
-            'addtime'     => 'Addtime',
-            'is_delete'   => 'Is Delete',
-            'latitude'      => '地址纬度',
-            'longitude'      => '地址经度',
-        ];
-    }
-
-    public function beforeSave($insert)
-    {
-        $this->name = Html::encode($this->name);
-        $this->mobile = Html::encode($this->mobile);
-        $this->detail = Html::encode($this->detail);
-        return parent::beforeSave($insert);
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use app\models\common\admin\log\CommonActionLog;
+use Yii;
+use yii\helpers\Html;
+
+/**
+ * This is the model class for table "{{%address}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $user_id
+ * @property string $name
+ * @property string $mobile
+ * @property integer $province_id
+ * @property string $province
+ * @property integer $city_id
+ * @property string $city
+ * @property integer $district_id
+ * @property string $district
+ * @property string $detail
+ * @property integer $is_default
+ * @property integer $addtime
+ * @property integer $is_delete
+ * @property string $latitude
+ * @property string $longitude
+ */
+class Address extends \yii\db\ActiveRecord
+{
+    /**
+     *  默认状态:默认地址
+     */
+    const DEFAULT_STATUS_TRUE = 1;
+
+    /**
+     *  默认状态:非默认地址
+     */
+    const DEFAULT_STATUS_FALSE = 0;
+
+    /**
+     * 删除状态:已删除
+     */
+    const DELETE_STATUS_TRUE = 1;
+
+    /**
+     * 删除状态:未删除
+     */
+    const DELETE_STATUS_FALSE = 0;
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%address}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'user_id', 'name', 'mobile', 'province', 'city', 'district', 'detail'], 'required'],
+            [['store_id', 'user_id', 'province_id', 'city_id', 'district_id', 'town_id', 'village_id', 'is_default', 'addtime', 'is_delete'], 'integer'],
+            [['name', 'mobile', 'province', 'city', 'district','town', 'village', 'latitude', 'longitude'], 'string', 'max' => 255],
+            [['detail'], 'string', 'max' => 1000],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id'          => 'ID',
+            'store_id'    => 'Store ID',
+            'user_id'     => 'User ID',
+            'name'        => '姓名',
+            'mobile'      => '手机号',
+            'province_id' => 'Province ID',
+            'province'    => '省份名称',
+            'city_id'     => 'City ID',
+            'city'        => '城市名称',
+            'district_id' => 'District ID',
+            'district'    => '县区名称',
+            'town_id' => 'town ID',
+            'town'    => '镇名称',
+            'village_id' => 'Village ID',
+            'village'    => '村名称',
+            'detail'      => '详细地址',
+            'is_default'  => '是否是默认地址:0=否,1=是',
+            'addtime'     => 'Addtime',
+            'is_delete'   => 'Is Delete',
+            'latitude'      => '地址纬度',
+            'longitude'      => '地址经度',
+        ];
+    }
+
+    public function beforeSave($insert)
+    {
+        $this->name = Html::encode($this->name);
+        $this->mobile = Html::encode($this->mobile);
+        $this->detail = Html::encode($this->detail);
+        return parent::beforeSave($insert);
+    }
+}

+ 254 - 265
models/Admin.php

@@ -1,265 +1,254 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-use yii\web\IdentityInterface;
-use yii\behaviors\TimestampBehavior;
-
-/**
- * Class Admin
- * @package app\modules\common\models
- *
- * @property integer $id
- * @property integer $province_id
- * @property integer $city_id
- * @property integer $district_id
- * @property integer $area_level
- * @property string $access_token
- * @property string $created_at
- * @property string $updated_at
- * @property string $username
- * @property string $password
- * @property integer $mobile
- * @property string $remark
- * @property string $email
- * @property string $name
- * @property string $avatar
- * @property integer $is_delete
- * @property integer $store_id
- * @property string $type
- * @property integer $type_id
- * @property integer $max_app_count
- * @property integer $expire_time
- * @property integer $saas_user_id
- * @property string $max_price
- * @property double $rate
- * @property integer $is_enable
- * @property string $address
- */
-class Admin extends ActiveRecord
-{
-    const ADMIN_NORMAL = 0; // 正常
-    const ADMIN_DELETE = 1; // 已删除
-
-    const ADMIN_ENABLE = 1; // 开启
-    const ADMIN_DISABLE = 0; // 禁用
-
-    const ADMIN_TYPE_DEFAULT = 'admin'; // 平台管理员
-    const ADMIN_TYPE_SUPPLIER = 'supplier'; // 供货商
-    const ADMIN_TYPE_MCH = 'mch'; // 入驻商
-    CONST ADMIN_TYPE_MCH_BRANDS = 'mch_brands'; // 入住商品牌管理员
-    const ADMIN_TYPE_MD = 'md'; // 门店
-    const ADMIN_TYPE_STORE = 'store'; // 商城
-    const ADMIN_TYPE_STAFF = 'staff'; // 员工
-    const ADMIN_TYPE_SAAS_STAFF = 'saas_staff';
-    const ADMIN_TYPE_FRONT_AGENT = 'front_agent'; // 前置仓
-    const ADMIN_TYPE_GOODS_AGENT = 'goods_agent'; // 产品代理
-    const ADMIN_TYPE_BD_AGENT = 'bd_agent'; // 推广代理
-    const ADMIN_TYPE_MINI_ADMIN = 'mini_admin'; // 小程序管理员
-    const ADMIN_TYPE_FRONT_AGENT_STAFF = 'front_agent_staff'; // 前置仓员工
-
-    public static function tableName()
-    {
-        return '{{%admin}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                // 自动更新创建和更新时间
-                'class' => TimestampBehavior::class,
-                'value' => time()
-            ]
-        ];
-    }
-
-    public function rules()
-    {
-        return [
-            [['is_delete', 'store_id', 'type_id', 'max_app_count', 'expire_time', 'saas_user_id', 'is_enable'], 'integer'],
-	        [['max_price', 'rate'], 'number'],
-            [['access_token'], 'string', 'max' => 60],
-            [['email', 'name', 'username', 'password', 'type'], 'string', 'max' => 100],
-            [['avatar'], 'string', 'max' => 255],
-            [['email'], 'email'],
-            [['access_token', 'create_at', 'update_at'], 'safe'],
-            [['address', 'mobile'], 'string']
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'province_id' => 'province_id',
-            'city_id' => 'city_id',
-            'district_id' => 'district_id',
-            'area_level' => 'area_level',
-            'access_token' => 'access token',
-            'create_at' => '创建时间',
-            'update_at' => '更新时间',
-            'username' => '用户名',
-            'password' => '密码',
-            'mobile' => '手机号',
-            'remark' => '备注',
-            'email' => '邮箱',
-            'name' => '昵称',
-            'avatar' => '头像',
-            'is_delete' => '是否已删除',
-            'store_id' => 'store_id',
-            'type' => '管理员类型',
-            'type_id' => 'type id',
-            'max_app_count' => '最大创建商城数量',
-            'expire_time' => '过期时间',
-            'max_price' => '允许设置的最大佣金',
-            'rate' => '代理商服务费率',
-            'is_enable' => '是否开启',
-            'address' => '代理地址'
-        ];
-    }
-
-    public function beforeSave($insert)
-    {
-        // 创建用户自动赋值access_token
-        if (parent::beforeSave($insert)) {
-            if ($this->isNewRecord) {
-                $this->access_token = \Yii::$app->security->generateRandomString();
-            }
-            if (empty($this->max_price)) {
-                $this->max_price = 0.00;
-            }
-            if (empty($this->rate)) {
-                $this->rate = 0.00;
-            }
-
-            $this->mobile = \str_replace(' ', '', $this->mobile);
-            
-            if($this->type == 'store' && $this->saas_user_id > 0){
-                if($this->isNewRecord){
-                    $is = self::find()->where(['type' => 'store', 'saas_user_id' => $this->saas_user_id, 'is_delete' => 0])->one();
-                }else{
-                    $is = self::find()->where(['type' => 'store', 'saas_user_id' => $this->saas_user_id, 'is_delete' => 0])->andWhere(['!=', 'id', $this->id])->one();
-                }
-                if($is){
-                    $this->addError('mobile', '操作失败,其他管理员['. $is->username .']已绑定此用户!请更换');
-                    return false;
-                }
-            }
-            return true;
-        }
-        return false;
-    }
-
-    public function afterSave($insert, $changedAttributes)
-    {
-        parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
-        if ($this->type === self::ADMIN_TYPE_STORE) {
-            $result = SaasStoreReferral::storeBindParent($this->type_id);
-            debug_log(['添加店铺推荐人' => $result], 'storeReferral.log');
-
-        }
-
-    }
-
-    /**
-     * @param int|string $id
-     * @return Admin|IdentityInterface|null
-     */
-    public static function findIdentity($id)
-    {
-        return static::findOne($id);
-    }
-
-    /**
-     * @param mixed $token
-     * @param null $type
-     * @return Admin|IdentityInterface|null
-     */
-    public static function findIdentityByAccessToken($token, $type = null)
-    {
-        return static::findOne(['access_token' => $token, 'is_delete' => 0]);
-    }
-
-    /**
-     * @param $username
-     * @return Admin|null
-     */
-    public static function findByUsername($username)
-    {
-        return static::findOne(['username' => $username, 'is_delete' => 0]);
-    }
-
-    /**
-     * @param $email
-     * @return Admin|null
-     */
-    public static function findByEmail($email)
-    {
-        return static::findOne(['email' => $email, 'is_delete' => 0]);
-    }
-
-    /**
-     * @param $mobile
-     * @return Admin|null
-     */
-    public static function findByMobile($mobile)
-    {
-        return static::findOne(['mobile' => $mobile, 'is_delete' => 0]);
-    }
-
-    /**
-     * @return int|string
-     */
-    public function getId()
-    {
-        return $this->id;
-    }
-
-    /**
-     * 刷新token
-     * @return bool
-     */
-    public function refreshToken()
-    {
-        $this->access_token = \Yii::$app->security->generateRandomString();
-        return $this->save();
-    }
-
-    /**
-     * 验证密码
-     * @param $password
-     * @return bool
-     */
-    public function validatePassword($password)
-    {
-        return \Yii::$app->security->validatePassword($password, $this->password);
-    }
-
-    /**
-     * 获取角色
-     * @return \yii\db\ActiveQuery
-     * @throws \yii\base\InvalidConfigException
-     */
-    public function getRoles()
-    {
-        return $this->hasMany(AuthRole::class, ['id' => 'role_id'])
-            ->viaTable('{{%admin_role}}', ['admin_id' => 'id']);
-    }
-
-    /**
-     * 获取平台角色
-     * @return \yii\db\ActiveQuery
-     * @throws \yii\base\InvalidConfigException
-     */
-    public function getSaasRoles()
-    {
-        return $this->hasMany(SaasAuthRole::class, ['id' => 'role_id'])
-            ->viaTable('{{%saas_admin_role}}', ['admin_id' => 'id']);
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\web\IdentityInterface;
+use yii\behaviors\TimestampBehavior;
+
+/**
+ * Class Admin
+ * @package app\modules\common\models
+ *
+ * @property integer $id
+ * @property integer $province_id
+ * @property integer $city_id
+ * @property integer $district_id
+ * @property integer $street_id
+ * @property integer $area_level
+ * @property string $access_token
+ * @property string $created_at
+ * @property string $updated_at
+ * @property string $username
+ * @property string $password
+ * @property integer $mobile
+ * @property string $remark
+ * @property string $email
+ * @property string $name
+ * @property string $avatar
+ * @property integer $is_delete
+ * @property integer $store_id
+ * @property string $type
+ * @property integer $type_id
+ * @property integer $max_app_count
+ * @property integer $expire_time
+ * @property integer $saas_user_id
+ * @property string $max_price
+ * @property double $rate
+ * @property integer $is_enable
+ * @property integer $advert_push_user_id
+ * @property string $address
+ */
+class Admin extends ActiveRecord
+{
+    const ADMIN_NORMAL = 0; // 正常
+    const ADMIN_DELETE = 1; // 已删除
+
+    const ADMIN_ENABLE = 1; // 开启
+    const ADMIN_DISABLE = 0; // 禁用
+
+    const ADMIN_TYPE_DEFAULT = 'admin'; // 平台管理员
+    const ADMIN_TYPE_SUPPLIER = 'supplier'; // 供货商
+    const ADMIN_TYPE_MCH = 'mch'; // 入驻商
+    const ADMIN_TYPE_MD = 'md'; // 门店
+    const ADMIN_TYPE_STORE = 'store'; // 商城
+    const ADMIN_TYPE_STAFF = 'staff'; // 员工
+    const ADMIN_TYPE_SAAS_STAFF = 'saas_staff';
+    const ADMIN_TYPE_FRONT_AGENT = 'front_agent'; // 前置仓
+    const ADMIN_TYPE_GOODS_AGENT = 'goods_agent'; // 产品代理
+    const ADMIN_TYPE_BD_AGENT = 'bd_agent'; // 推广代理
+    const ADMIN_TYPE_AREA_AGENT = 'area_agent'; // 区域代理
+    const ADMIN_TYPE_MINI_ADMIN = 'mini_admin'; // 小程序管理员
+
+    public static function tableName()
+    {
+        return '{{%admin}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                // 自动更新创建和更新时间
+                'class' => TimestampBehavior::class,
+                'value' => time()
+            ]
+        ];
+    }
+
+    public function rules()
+    {
+        return [
+            [['is_delete', 'store_id', 'type_id', 'max_app_count', 'expire_time', 'saas_user_id', 'is_enable','advert_push_user_id'], 'integer'],
+	        [['max_price', 'rate'], 'number'],
+            [['access_token'], 'string', 'max' => 60],
+            [['email', 'name', 'username', 'password', 'type'], 'string', 'max' => 100],
+            [['avatar'], 'string', 'max' => 255],
+            [['email'], 'email'],
+            [['access_token', 'create_at', 'update_at'], 'safe'],
+            [['address', 'mobile'], 'string']
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'province_id' => 'province_id',
+            'city_id' => 'city_id',
+            'district_id' => 'district_id',
+            'area_level' => 'area_level',
+            'access_token' => 'access token',
+            'create_at' => '创建时间',
+            'update_at' => '更新时间',
+            'username' => '用户名',
+            'password' => '密码',
+            'mobile' => '手机号',
+            'remark' => '备注',
+            'email' => '邮箱',
+            'name' => '昵称',
+            'avatar' => '头像',
+            'is_delete' => '是否已删除',
+            'store_id' => 'store_id',
+            'type' => '管理员类型',
+            'type_id' => 'type id',
+            'max_app_count' => '最大创建商城数量',
+            'expire_time' => '过期时间',
+            'max_price' => '允许设置的最大佣金',
+            'rate' => '代理商服务费率',
+            'is_enable' => '是否开启',
+            'address' => '代理地址'
+        ];
+    }
+
+    public function beforeSave($insert)
+    {
+        // 创建用户自动赋值access_token
+        if (parent::beforeSave($insert)) {
+            if ($this->isNewRecord) {
+                $this->access_token = \Yii::$app->security->generateRandomString();
+            }
+            if (empty($this->max_price)) {
+                $this->max_price = 0.00;
+            }
+            if (empty($this->rate)) {
+                $this->rate = 0.00;
+            }
+
+            $this->mobile = \str_replace(' ', '', $this->mobile);
+
+            /*if($this->type == 'store' && $this->saas_user_id > 0){
+                if($this->isNewRecord){
+                    $is = self::find()->where(['type' => 'store', 'saas_user_id' => $this->saas_user_id, 'is_delete' => 0])->one();
+                }else{
+                    $is = self::find()->where(['type' => 'store', 'saas_user_id' => $this->saas_user_id, 'is_delete' => 0])->andWhere(['!=', 'id', $this->id])->one();
+                }
+                if($is){
+                    $this->addError('mobile', '操作失败,其他管理员['. $is->username .']已绑定此用户!请更换');
+                    return false;
+                }
+            }*/
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * @param int|string $id
+     * @return Admin|IdentityInterface|null
+     */
+    public static function findIdentity($id)
+    {
+        return static::findOne($id);
+    }
+
+    /**
+     * @param mixed $token
+     * @param null $type
+     * @return Admin|IdentityInterface|null
+     */
+    public static function findIdentityByAccessToken($token, $type = null)
+    {
+        return static::findOne(['access_token' => $token, 'is_delete' => 0]);
+    }
+
+    /**
+     * @param $username
+     */
+    public static function findByUsername($username)
+    {
+        return static::find()->where(['is_delete' => 0])->andWhere(['or',['username' => $username,],['name' => $username]])->one();
+    }
+
+    /**
+     * @param $email
+     * @return Admin|null
+     */
+    public static function findByEmail($email)
+    {
+        return static::findOne(['email' => $email, 'is_delete' => 0]);
+    }
+
+    /**
+     * @param $mobile
+     * @return Admin|null
+     */
+    public static function findByMobile($mobile)
+    {
+        return static::findOne(['mobile' => $mobile, 'is_delete' => 0]);
+    }
+
+    /**
+     * @return int|string
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * 刷新token
+     * @return bool
+     */
+    public function refreshToken()
+    {
+        $this->access_token = \Yii::$app->security->generateRandomString();
+        return $this->save();
+    }
+
+    /**
+     * 验证密码
+     * @param $password
+     * @return bool
+     */
+    public function validatePassword($password)
+    {
+        return \Yii::$app->security->validatePassword($password, $this->password);
+    }
+
+    /**
+     * 获取角色
+     * @return \yii\db\ActiveQuery
+     * @throws \yii\base\InvalidConfigException
+     */
+    public function getRoles()
+    {
+        return $this->hasMany(AuthRole::class, ['id' => 'role_id'])
+            ->viaTable('{{%admin_role}}', ['admin_id' => 'id']);
+    }
+
+    /**
+     * 获取平台角色
+     * @return \yii\db\ActiveQuery
+     * @throws \yii\base\InvalidConfigException
+     */
+    public function getSaasRoles()
+    {
+        return $this->hasMany(SaasAuthRole::class, ['id' => 'role_id'])
+            ->viaTable('{{%saas_admin_role}}', ['admin_id' => 'id']);
+    }
+}

+ 39 - 39
models/AdminRole.php

@@ -1,39 +1,39 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-
-/**
- * Class AuthRole
- * @package app\modules\common\models
- * @property integer $admin_id
- * @property string $role_id
- */
-class AdminRole extends ActiveRecord
-{
-    public static function tableName()
-    {
-        return '{{%admin_role}}';
-    }
-
-    public function rules()
-    {
-        return [
-            [['admin_id'], 'integer'],
-            [['role_id'], 'integer'],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'admin_id' => '账号ID',
-            'role_key' => '角色ID',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+
+/**
+ * Class AuthRole
+ * @package app\modules\common\models
+ * @property integer $admin_id
+ * @property string $role_id
+ */
+class AdminRole extends ActiveRecord
+{
+    public static function tableName()
+    {
+        return '{{%admin_role}}';
+    }
+
+    public function rules()
+    {
+        return [
+            [['admin_id'], 'integer'],
+            [['role_id'], 'integer'],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'admin_id' => '账号ID',
+            'role_key' => '角色ID',
+        ];
+    }
+}

+ 55 - 55
models/AdoptGoodsDevice.php

@@ -1,56 +1,56 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\behaviors\TimestampBehavior;
-
-class AdoptGoodsDevice extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%adopt_goods_device}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                // 自动更新创建和更新时间
-                'class' => TimestampBehavior::class,
-                'value' => time()
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['goods_id', 'store_id', 'device_id', 'is_delete'], 'integer'],
-            [['is_delete'], 'default', 'value' => 0]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'goods_id' => 'Goods ID',
-            'store_id' => 'Store ID',
-            'device_id' => '设备ID  多个分类用英文逗号隔开',
-            'is_delete' => 'Is Delete',
-        ];
-    }
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\behaviors\TimestampBehavior;
+
+class AdoptGoodsDevice extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%adopt_goods_device}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                // 自动更新创建和更新时间
+                'class' => TimestampBehavior::class,
+                'value' => time()
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['goods_id', 'store_id', 'device_id', 'is_delete'], 'integer'],
+            [['is_delete'], 'default', 'value' => 0]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'goods_id' => 'Goods ID',
+            'store_id' => 'Store ID',
+            'device_id' => '设备ID  多个分类用英文逗号隔开',
+            'is_delete' => 'Is Delete',
+        ];
+    }
 }

+ 69 - 69
models/AgentApply.php

@@ -1,69 +1,69 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_apply}}".
- *
- * @property integer $id
- * @property string  $username
- * @property string  $password
- * @property string  $mobile
- * @property string  $name
- * @property integer $saas_user_id
- * @property integer $province_id
- * @property integer $city_id
- * @property integer $district_id
- * @property integer $area_level
- * @property string  $address
- * @property string  $lat
- * @property string  $lng
- * @property integer $agent_type
- * @property integer $status
- * @property integer $is_delete
- * @property integer $admin_id
- * @property string  $reason
- */
-class AgentApply extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_apply}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [["id", "saas_user_id", "province_id", "city_id", "district_id", "agent_type", "status", "is_delete", "admin_id", "area_level"], 'integer'],
-            [["username", "password", "mobile", "name", "address", "lat", "lng", "reason"], 'string']
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_apply}}".
+ *
+ * @property integer $id
+ * @property string  $username
+ * @property string  $password
+ * @property string  $mobile
+ * @property string  $name
+ * @property integer $saas_user_id
+ * @property integer $province_id
+ * @property integer $city_id
+ * @property integer $district_id
+ * @property integer $area_level
+ * @property string  $address
+ * @property string  $lat
+ * @property string  $lng
+ * @property integer $agent_type
+ * @property integer $status
+ * @property integer $is_delete
+ * @property integer $admin_id
+ * @property string  $reason
+ */
+class AgentApply extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_apply}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [["id", "saas_user_id", "province_id", "city_id", "district_id", "agent_type", "status", "is_delete", "admin_id", "area_level"], 'integer'],
+            [["username", "password", "mobile", "name", "address", "lat", "lng", "reason"], 'string']
+        ];
+    }
+
+}

+ 57 - 57
models/AgentBind.php

@@ -1,57 +1,57 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_bind}}".
- *
- * @property integer $id
- * @property integer $type
- * @property integer $admin_id
- * @property integer $parent_admin_id
- * @property integer $is_delete
- * @property integer $created_at
- * @property integer $updated_at
- */
-class AgentBind extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_bind}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'type', 'admin_id', 'parent_admin_id', 'is_delete', 'created_at', 'updated_at'], 'integer']
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_bind}}".
+ *
+ * @property integer $id
+ * @property integer $type
+ * @property integer $admin_id
+ * @property integer $parent_admin_id
+ * @property integer $is_delete
+ * @property integer $created_at
+ * @property integer $updated_at
+ */
+class AgentBind extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_bind}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'type', 'admin_id', 'parent_admin_id', 'is_delete', 'created_at', 'updated_at'], 'integer']
+        ];
+    }
+
+}

+ 83 - 99
models/AgentFrontBind.php

@@ -1,99 +1,83 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_front_bind}}".
- *
- * @property integer $id
- * @property integer $front_agent_admin_id
- * @property integer $type_id
- * @property integer $type
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $is_delete
- * @property integer $status
- * @property integer $md_id
- * @property integer $is_cloud_delivery
- */
-class AgentFrontBind extends \yii\db\ActiveRecord
-{
-    const TYPE_SUPPLIER = 0;//供货商类型
-    const TYPE_STORE = 1;//商家类型
-
-    const IS_CLOUD_DELIVERY_TRUE = 1;
-    const IS_CLOUD_DELIVERY_FALSE = 0;
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_front_bind}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'front_agent_admin_id', 'type_id', 'type', 'created_at', 'updated_at', 'is_delete', 'status', 'md_id'], 'integer']
-        ];
-    }
-
-
-    public static function getStoreBindFrontAgent($store_id) {
-        return self::find()->alias('agb')->leftJoin(['a' => Admin::tableName()], 'agb.front_agent_admin_id = a.id')
-            ->where(['agb.type' => self::TYPE_STORE, 'agb.type_id' => $store_id, 'agb.is_delete' => 0, 'agb.status' => 1])
-            ->select('a.id front_agent_admin_id, a.name')->groupBy('a.id')->asArray()->all();
-    }
-
-
-    //获取仓库绑定的供货商
-    public static function getAgentFrontBindSupplierId($front_agent_admin_id) {
-        return self::find()->alias('a')
-            ->leftJoin(['s' => Supplier::tableName()], 'a.type_id = s.id AND a.type = ' . self::TYPE_SUPPLIER)
-            ->where([
-                'a.type' => self::TYPE_SUPPLIER,
-                'a.is_delete' => 0,
-                'a.status' => 1,
-                's.is_delete' => 0,
-                'a.front_agent_admin_id' => $front_agent_admin_id
-            ])
-            ->groupBy('s.cloud_supplier_id')
-            ->select('s.cloud_supplier_id')->column();
-    }
-
-    //获取仓库绑定的门店列表
-    public static function getAgentFrontBindMdList($front_agent_admin_id) {
-        return self::find()->alias('a')
-            ->leftJoin(['md' => Md::tableName()], 'a.md_id = md.id ')
-            ->where([
-                'a.is_delete' => 0,
-                'a.status' => 1,
-                'md.is_delete' => 0,
-                'a.front_agent_admin_id' => $front_agent_admin_id
-            ])->select('md.id, md.name')->groupBy('md.id')->asArray()->all();
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_front_bind}}".
+ *
+ * @property integer $id
+ * @property integer $front_agent_admin_id
+ * @property integer $type_id
+ * @property integer $type
+ * @property integer $created_at
+ * @property integer $updated_at
+ * @property integer $is_delete
+ * @property integer $status
+ * @property integer $md_id
+ */
+class AgentFrontBind extends \yii\db\ActiveRecord
+{
+    const TYPE_SUPPLIER = 0;//供货商类型
+    const TYPE_STORE = 1;//商家类型
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_front_bind}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'front_agent_admin_id', 'type_id', 'type', 'created_at', 'updated_at', 'is_delete', 'status', 'md_id'], 'integer']
+        ];
+    }
+
+
+    public static function getStoreBindFrontAgent($store_id) {
+        return self::find()->alias('agb')->leftJoin(['a' => Admin::tableName()], 'agb.front_agent_admin_id = a.id')
+            ->where(['agb.type' => self::TYPE_STORE, 'agb.type_id' => $store_id, 'agb.is_delete' => 0, 'agb.status' => 1])
+            ->select('a.id front_agent_admin_id, a.name')->groupBy('a.id')->asArray()->all();
+    }
+
+
+    //获取仓库绑定的供货商
+    public static function getAgentFrontBindSupplierId($front_agent_admin_id) {
+        return self::find()->alias('a')
+            ->leftJoin(['s' => Supplier::tableName()], 'a.type_id = s.id AND a.type = ' . self::TYPE_SUPPLIER)
+            ->where([
+                'a.type' => self::TYPE_SUPPLIER,
+                'a.is_delete' => 0,
+                'a.status' => 1,
+                's.is_delete' => 0,
+                'a.front_agent_admin_id' => $front_agent_admin_id
+            ])
+            ->groupBy('s.cloud_supplier_id')
+            ->select('s.cloud_supplier_id')->column();
+    }
+}

+ 57 - 57
models/AgentFrontErpCloudGoods.php

@@ -1,57 +1,57 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_front_erp_cloud_goods}}".
- *
- * @property integer $id
- * @property integer $cloud_goods_id
- * @property integer $cloud_supplier_id
- * @property string  $goods_name
- * @property string  $goods_no
- * @property string  $cover_pic
- * @property string  $attr
- * @property integer $status
- * @property integer $is_delete
- * @property integer $created_at
- * @property integer $updated_at
-
- */
-class AgentFrontErpCloudGoods extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_front_erp_cloud_goods}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-    public function rules()
-    {
-        return [
-            [['goods_name', 'cover_pic', 'attr', 'goods_no'], 'string'],
-            [['id', 'cloud_goods_id', 'cloud_supplier_id', 'status', 'is_delete', 'created_at', 'updated_at'], 'integer']
-        ];
-    }
-
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_front_erp_cloud_goods}}".
+ *
+ * @property integer $id
+ * @property integer $cloud_goods_id
+ * @property integer $cloud_supplier_id
+ * @property string  $goods_name
+ * @property string  $goods_no
+ * @property string  $cover_pic
+ * @property string  $attr
+ * @property integer $status
+ * @property integer $is_delete
+ * @property integer $created_at
+ * @property integer $updated_at
+
+ */
+class AgentFrontErpCloudGoods extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_front_erp_cloud_goods}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+    public function rules()
+    {
+        return [
+            [['goods_name', 'cover_pic', 'attr', 'goods_no'], 'string'],
+            [['id', 'cloud_goods_id', 'cloud_supplier_id', 'status', 'is_delete', 'created_at', 'updated_at'], 'integer']
+        ];
+    }
+
+
+}

+ 133 - 133
models/AgentFrontErpInventory.php

@@ -1,133 +1,133 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_front_erp_inventory}}".
- *
- * @property integer $id
- * @property string $goods_no
- */
-class AgentFrontErpInventory extends \yii\db\ActiveRecord
-{
-    public $sync2Goods = 1;
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_front_erp_inventory}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-    public function afterSave($insert, $changedAttributes)
-    {
-        parent::afterSave($insert, $changedAttributes);
-//        if(!$insert && $changedAttributes['num'] && $this->sync2Goods){
-//            queue_push(new \app\jobs\ErpJob([
-//                'in_action' => 'executeAgentFrontErpInventory2Goods',
-//                'id' => $this->id,
-//            ]), 30);
-//        }
-
-        //TODO 入库出库时 此处调用云仓供货商同步商品数量的方案 进行同步数量
-
-
-    }
-
-//    public static function num2Goods($id)
-//    {
-//        $ei = AgentFrontErpInventory::findOne($id);
-//
-//        if ($ei) {
-//            $goods_arr = Goods::find()->where(['cloud_goods_id' => $ei->goods_id])->select('id, attr')->asArray()->all();
-//            $attr_id = [];
-//            foreach ($goods_arr as $goods_) {
-//                $attr_list = json_decode($goods_['attr'], true);
-//                foreach ($attr_list as $attr) {
-//                    if ($attr['no'] === $ei->goods_no) {
-//                        $attr_id = array_column($attr['attr_list'], 'attr_id');
-//                    }
-//                }
-//                $numAdd = Goods::numAddStatic($goods_['id'], $attr_id, $ei->num, 1);
-//                if(!$numAdd){
-//                    \Yii::error([__METHOD__, 'erp同步库存到商品失败!', $ei->attributes]);
-//                }
-//            }
-//        }
-//
-//
-//    }
-
-    public static function logSave ($ei, $num, $type = AgentFrontErpInventoryLog::LOG_TYPE_ORDER, $order_id = 0, $order_no = '')
-    {
-        $t = \Yii::$app->db->beginTransaction();
-        try {
-
-            $model = new AgentFrontErpInventoryLog();
-            $model->inventory_id = $ei['id'];
-            $model->attr_ids = $ei['attr_ids'];
-            $model->type = $type;
-            $model->order_id = $order_id;
-            $model->order_no = $order_no;
-            $model->before = $ei['num'];
-            $model->after = $ei['num'] + $num;
-            $model->num = $num;
-            if (!$model->save()) {
-                \Yii::error([__METHOD__, $model->attributes]);
-                throw new \Exception('日志保存失败!' . array_shift($model->getFirstErrors()));
-            }
-            $ei->num = $model->after;
-            if($type == ErpInventoryLog::LOG_TYPE_PURCHASEOUT && $ei->num < 0){
-                \Yii::error([__METHOD__, $ei->attributes]);
-                throw new \Exception('库存保存失败!ID:'. $ei->id .'出库数量大于库存');
-            }
-            if (!$ei->save()) {
-                \Yii::error([__METHOD__, $ei->attributes]);
-                throw new \Exception('库存保存失败!' . array_shift($ei->getFirstErrors()));
-            }
-
-            $ei_attr_info = json_decode($ei->attr_info, true);
-            if (!empty($ei_attr_info)) {
-                $updateAttrList = [
-                    [
-                        'attr_id_list' => array_column($ei_attr_info['attr_list'], 'attr_id'),
-                        'num' => 0
-                    ]
-                ];
-                $form = new \app\modules\admin\models\SupplierForm();
-                $res = $form->setGoodsAttrNum($ei->supplier_id, $ei->goods_id, $updateAttrList);
-            }
-
-            $t->commit();
-            return [
-                'code' => 0,
-                'msg' => '操作成功!'
-            ];
-        } catch (\Exception $e) {
-            $t->rollBack();
-            \Yii::error($e);
-            return [
-                'code' => 1,
-                'msg' => $e->getMessage()
-            ];
-        }
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_front_erp_inventory}}".
+ *
+ * @property integer $id
+ * @property string $goods_no
+ */
+class AgentFrontErpInventory extends \yii\db\ActiveRecord
+{
+    public $sync2Goods = 1;
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_front_erp_inventory}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+    public function afterSave($insert, $changedAttributes)
+    {
+        parent::afterSave($insert, $changedAttributes);
+//        if(!$insert && $changedAttributes['num'] && $this->sync2Goods){
+//            queue_push(new \app\jobs\ErpJob([
+//                'in_action' => 'executeAgentFrontErpInventory2Goods',
+//                'id' => $this->id,
+//            ]), 30);
+//        }
+
+        //TODO 入库出库时 此处调用云仓供货商同步商品数量的方案 进行同步数量
+
+
+    }
+
+//    public static function num2Goods($id)
+//    {
+//        $ei = AgentFrontErpInventory::findOne($id);
+//
+//        if ($ei) {
+//            $goods_arr = Goods::find()->where(['cloud_goods_id' => $ei->goods_id])->select('id, attr')->asArray()->all();
+//            $attr_id = [];
+//            foreach ($goods_arr as $goods_) {
+//                $attr_list = json_decode($goods_['attr'], true);
+//                foreach ($attr_list as $attr) {
+//                    if ($attr['no'] === $ei->goods_no) {
+//                        $attr_id = array_column($attr['attr_list'], 'attr_id');
+//                    }
+//                }
+//                $numAdd = Goods::numAddStatic($goods_['id'], $attr_id, $ei->num, 1);
+//                if(!$numAdd){
+//                    \Yii::error([__METHOD__, 'erp同步库存到商品失败!', $ei->attributes]);
+//                }
+//            }
+//        }
+//
+//
+//    }
+
+    public static function logSave ($ei, $num, $type = AgentFrontErpInventoryLog::LOG_TYPE_ORDER, $order_id = 0, $order_no = '')
+    {
+        $t = \Yii::$app->db->beginTransaction();
+        try {
+
+            $model = new AgentFrontErpInventoryLog();
+            $model->inventory_id = $ei['id'];
+            $model->attr_ids = $ei['attr_ids'];
+            $model->type = $type;
+            $model->order_id = $order_id;
+            $model->order_no = $order_no;
+            $model->before = $ei['num'];
+            $model->after = $ei['num'] + $num;
+            $model->num = $num;
+            if (!$model->save()) {
+                \Yii::error([__METHOD__, $model->attributes]);
+                throw new \Exception('日志保存失败!' . array_shift($model->getFirstErrors()));
+            }
+            $ei->num = $model->after;
+            if($type == ErpInventoryLog::LOG_TYPE_PURCHASEOUT && $ei->num < 0){
+                \Yii::error([__METHOD__, $ei->attributes]);
+                throw new \Exception('库存保存失败!ID:'. $ei->id .'出库数量大于库存');
+            }
+            if (!$ei->save()) {
+                \Yii::error([__METHOD__, $ei->attributes]);
+                throw new \Exception('库存保存失败!' . array_shift($ei->getFirstErrors()));
+            }
+
+            $ei_attr_info = json_decode($ei->attr_info, true);
+            if (!empty($ei_attr_info)) {
+                $updateAttrList = [
+                    [
+                        'attr_id_list' => array_column($ei_attr_info['attr_list'], 'attr_id'),
+                        'num' => 0
+                    ]
+                ];
+                $form = new \app\modules\admin\models\SupplierForm();
+                $res = $form->setGoodsAttrNum($ei->supplier_id, $ei->goods_id, $updateAttrList);
+            }
+
+            $t->commit();
+            return [
+                'code' => 0,
+                'msg' => '操作成功!'
+            ];
+        } catch (\Exception $e) {
+            $t->rollBack();
+            \Yii::error($e);
+            return [
+                'code' => 1,
+                'msg' => $e->getMessage()
+            ];
+        }
+    }
+
+}

+ 41 - 41
models/AgentFrontErpInventoryLog.php

@@ -1,41 +1,41 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_front_erp_inventory_log}}".
- *
- * @property integer $id
- */
-class AgentFrontErpInventoryLog extends \yii\db\ActiveRecord
-{
-    
-    const LOG_TYPE_ORDER = 0;       //订单
-    const LOG_TYPE_PURCHASEIN = 1;  //入库
-    const LOG_TYPE_PURCHASEOUT = 2; //出库
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_front_erp_inventory_log}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_front_erp_inventory_log}}".
+ *
+ * @property integer $id
+ */
+class AgentFrontErpInventoryLog extends \yii\db\ActiveRecord
+{
+    
+    const LOG_TYPE_ORDER = 0;       //订单
+    const LOG_TYPE_PURCHASEIN = 1;  //入库
+    const LOG_TYPE_PURCHASEOUT = 2; //出库
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_front_erp_inventory_log}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+}

+ 41 - 41
models/AgentFrontErpPurchase.php

@@ -1,41 +1,41 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_front_erp_purchase}}".
- *
- * @property integer $id
- */
-class AgentFrontErpPurchase extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_front_erp_purchase}}';
-    }
-    
-    public static function saveList($order_id, $purchase) {
-        foreach($purchase as $item){
-            $model = new AgentFrontErpPurchase();
-            $model->inventory_id = $item['id'];
-            $model->num = $item['num'];
-            $model->purchase_order_id = $order_id;
-            if (!$model->save()) {
-                \Yii::error([__METHOD__, $model->attributes]);
-                throw new \Exception(array_shift($model->getFirstErrors()));
-            }
-        }
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_front_erp_purchase}}".
+ *
+ * @property integer $id
+ */
+class AgentFrontErpPurchase extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_front_erp_purchase}}';
+    }
+    
+    public static function saveList($order_id, $purchase) {
+        foreach($purchase as $item){
+            $model = new AgentFrontErpPurchase();
+            $model->inventory_id = $item['id'];
+            $model->num = $item['num'];
+            $model->purchase_order_id = $order_id;
+            if (!$model->save()) {
+                \Yii::error([__METHOD__, $model->attributes]);
+                throw new \Exception(array_shift($model->getFirstErrors()));
+            }
+        }
+    }
+
+}

+ 82 - 82
models/AgentFrontErpPurchaseOrder.php

@@ -1,82 +1,82 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_front_erp_purchase_order}}".
- *
- * @property integer $id
- * @property string  $order_no
- * @property integer $front_agent_admin_id
- * @property integer $supplier_id
- * @property integer $num
- * @property integer $order_status
- */
-class AgentFrontErpPurchaseOrder extends \yii\db\ActiveRecord
-{
-    const ORDER_STATUS_CREATE = 0;//采购单已生成
-
-    const ORDER_STATUS_SEND = 1;//供货商发货
-
-    const ORDER_STATUS_CONFIRM = 2;//仓库收货
-
-    const ORDER_STATUS_ARR = [
-        self::ORDER_STATUS_CREATE => "已创建采购单",
-        self::ORDER_STATUS_SEND => "供货商已发货",
-        self::ORDER_STATUS_CONFIRM => "已生成入库单",
-    ];
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_front_erp_purchase_order}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-    public function afterSave($insert, $changedAttributes)
-    {
-        parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
-        if (intval($this->order_status) === self::ORDER_STATUS_CONFIRM) {
-
-            $agentFrontErpPurchase = AgentFrontErpPurchase::find()->where(['purchase_order_id' => $this->id])->asArray()->all();
-            $purchase = [];
-            if ($agentFrontErpPurchase) {
-                foreach ($agentFrontErpPurchase as $erpPurchaseItem) {
-                    $purchase[] = [
-                        'id' => $erpPurchaseItem['inventory_id'],
-                        'num' => $erpPurchaseItem['num']
-                    ];
-                }
-            }
-
-            $form = new \app\modules\admin\models\agent\front_erp\PurchaseinForm();
-            $form->front_agent_admin_id = $this->front_agent_admin_id;
-            $form->supplier_id = $this->supplier_id;
-            $form->purchase = $purchase;
-            $res = $form->save();
-            if ($res['code'] !== 0) {
-
-            }
-
-        }
-        return true;
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_front_erp_purchase_order}}".
+ *
+ * @property integer $id
+ * @property string  $order_no
+ * @property integer $front_agent_admin_id
+ * @property integer $supplier_id
+ * @property integer $num
+ * @property integer $order_status
+ */
+class AgentFrontErpPurchaseOrder extends \yii\db\ActiveRecord
+{
+    const ORDER_STATUS_CREATE = 0;//采购单已生成
+
+    const ORDER_STATUS_SEND = 1;//供货商发货
+
+    const ORDER_STATUS_CONFIRM = 2;//仓库收货
+
+    const ORDER_STATUS_ARR = [
+        self::ORDER_STATUS_CREATE => "已创建采购单",
+        self::ORDER_STATUS_SEND => "供货商已发货",
+        self::ORDER_STATUS_CONFIRM => "已生成入库单",
+    ];
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_front_erp_purchase_order}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+    public function afterSave($insert, $changedAttributes)
+    {
+        parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
+        if (intval($this->order_status) === self::ORDER_STATUS_CONFIRM) {
+
+            $agentFrontErpPurchase = AgentFrontErpPurchase::find()->where(['purchase_order_id' => $this->id])->asArray()->all();
+            $purchase = [];
+            if ($agentFrontErpPurchase) {
+                foreach ($agentFrontErpPurchase as $erpPurchaseItem) {
+                    $purchase[] = [
+                        'id' => $erpPurchaseItem['inventory_id'],
+                        'num' => $erpPurchaseItem['num']
+                    ];
+                }
+            }
+
+            $form = new \app\modules\admin\models\agent\front_erp\PurchaseinForm();
+            $form->front_agent_admin_id = $this->front_agent_admin_id;
+            $form->supplier_id = $this->supplier_id;
+            $form->purchase = $purchase;
+            $res = $form->save();
+            if ($res['code'] !== 0) {
+
+            }
+
+        }
+        return true;
+    }
+
+}

+ 51 - 51
models/AgentFrontErpPurchasein.php

@@ -1,51 +1,51 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_front_erp_purchasein}}".
- *
- * @property integer $id
- */
-class AgentFrontErpPurchasein extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_front_erp_purchasein}}';
-    }
-    
-    public static function saveList($order, $purchase) {
-        $order_id = $order['id'];
-        $order_no = $order['order_no'];
-        foreach($purchase as $item){
-            $model = new AgentFrontErpPurchasein();
-            $model->inventory_id = $item['id'];
-            $model->num = $item['num'];
-            $model->purchase_order_id = $order_id;
-            if (!$model->save()) {
-                \Yii::error([__METHOD__, $model->attributes]);
-                throw new \Exception(array_shift($model->getFirstErrors()));
-            }
-            
-            $ei = AgentFrontErpInventory::findOne($model->inventory_id);
-            
-            $logSave = AgentFrontErpInventory::logSave($ei, $model->num, AgentFrontErpInventoryLog::LOG_TYPE_PURCHASEIN, $order_id, $order_no);
-            if ($logSave['code'] != 0) {
-                \Yii::error([__METHOD__, $logSave]);
-                throw new \Exception('库存日志保存失败!' . $logSave['msg']);
-            }
-        }
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_front_erp_purchasein}}".
+ *
+ * @property integer $id
+ */
+class AgentFrontErpPurchasein extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_front_erp_purchasein}}';
+    }
+    
+    public static function saveList($order, $purchase) {
+        $order_id = $order['id'];
+        $order_no = $order['order_no'];
+        foreach($purchase as $item){
+            $model = new AgentFrontErpPurchasein();
+            $model->inventory_id = $item['id'];
+            $model->num = $item['num'];
+            $model->purchase_order_id = $order_id;
+            if (!$model->save()) {
+                \Yii::error([__METHOD__, $model->attributes]);
+                throw new \Exception(array_shift($model->getFirstErrors()));
+            }
+            
+            $ei = AgentFrontErpInventory::findOne($model->inventory_id);
+            
+            $logSave = AgentFrontErpInventory::logSave($ei, $model->num, AgentFrontErpInventoryLog::LOG_TYPE_PURCHASEIN, $order_id, $order_no);
+            if ($logSave['code'] != 0) {
+                \Yii::error([__METHOD__, $logSave]);
+                throw new \Exception('库存日志保存失败!' . $logSave['msg']);
+            }
+        }
+    }
+
+}

+ 37 - 37
models/AgentFrontErpPurchaseinOrder.php

@@ -1,37 +1,37 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_front_erp_purchasein_order}}".
- *
- * @property integer $id
- */
-class AgentFrontErpPurchaseinOrder extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_front_erp_purchasein_order}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_front_erp_purchasein_order}}".
+ *
+ * @property integer $id
+ */
+class AgentFrontErpPurchaseinOrder extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_front_erp_purchasein_order}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+}

+ 51 - 51
models/AgentFrontErpPurchaseout.php

@@ -1,51 +1,51 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_front_erp_purchaseout}}".
- *
- * @property integer $id
- */
-class AgentFrontErpPurchaseout extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_front_erp_purchaseout}}';
-    }
-    
-    public static function saveList($order, $purchase) {
-        $order_id = $order['id'];
-        $order_no = $order['order_no'];
-        foreach($purchase as $item){
-            $model = new AgentFrontErpPurchaseout();
-            $model->inventory_id = $item['id'];
-            $model->num = $item['num'];
-            $model->purchase_order_id = $order_id;
-            if (!$model->save()) {
-                \Yii::error([__METHOD__, $model->attributes]);
-                throw new \Exception(array_shift($model->getFirstErrors()));
-            }
-            
-            $ei = AgentFrontErpInventory::findOne($model->inventory_id);
-            
-            $logSave = AgentFrontErpInventory::logSave($ei, -$model->num, AgentFrontErpInventoryLog::LOG_TYPE_PURCHASEOUT, $order_id, $order_no);
-            if ($logSave['code'] != 0) {
-                \Yii::error([__METHOD__, $logSave]);
-                throw new \Exception('库存日志保存失败!' . $logSave['msg']);
-            }
-        }
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_front_erp_purchaseout}}".
+ *
+ * @property integer $id
+ */
+class AgentFrontErpPurchaseout extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_front_erp_purchaseout}}';
+    }
+    
+    public static function saveList($order, $purchase) {
+        $order_id = $order['id'];
+        $order_no = $order['order_no'];
+        foreach($purchase as $item){
+            $model = new AgentFrontErpPurchaseout();
+            $model->inventory_id = $item['id'];
+            $model->num = $item['num'];
+            $model->purchase_order_id = $order_id;
+            if (!$model->save()) {
+                \Yii::error([__METHOD__, $model->attributes]);
+                throw new \Exception(array_shift($model->getFirstErrors()));
+            }
+            
+            $ei = AgentFrontErpInventory::findOne($model->inventory_id);
+            
+            $logSave = AgentFrontErpInventory::logSave($ei, -$model->num, AgentFrontErpInventoryLog::LOG_TYPE_PURCHASEOUT, $order_id, $order_no);
+            if ($logSave['code'] != 0) {
+                \Yii::error([__METHOD__, $logSave]);
+                throw new \Exception('库存日志保存失败!' . $logSave['msg']);
+            }
+        }
+    }
+
+}

+ 37 - 37
models/AgentFrontErpPurchaseoutOrder.php

@@ -1,37 +1,37 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_front_erp_purchaseout_order}}".
- *
- * @property integer $id
- */
-class AgentFrontErpPurchaseoutOrder extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_front_erp_purchaseout_order}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_front_erp_purchaseout_order}}".
+ *
+ * @property integer $id
+ */
+class AgentFrontErpPurchaseoutOrder extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_front_erp_purchaseout_order}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+}

+ 59 - 59
models/AgentGoodsBindGoods.php

@@ -1,59 +1,59 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_goods_bind_goods}}".
- *
- * @property integer $id
- * @property integer $goods_agent_admin_id
- * @property integer $front_agent_admin_id
- * @property integer $cloud_goods_id
- * @property integer $cloud_supplier_id
- * @property integer $status
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $is_delete
- */
-class AgentGoodsBindGoods extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_goods_bind_goods}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'goods_agent_admin_id', 'front_agent_admin_id', 'cloud_goods_id', 'cloud_supplier_id', 'status', 'created_at', 'updated_at', 'is_delete'], 'integer']
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_goods_bind_goods}}".
+ *
+ * @property integer $id
+ * @property integer $goods_agent_admin_id
+ * @property integer $front_agent_admin_id
+ * @property integer $cloud_goods_id
+ * @property integer $cloud_supplier_id
+ * @property integer $status
+ * @property integer $created_at
+ * @property integer $updated_at
+ * @property integer $is_delete
+ */
+class AgentGoodsBindGoods extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_goods_bind_goods}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'goods_agent_admin_id', 'front_agent_admin_id', 'cloud_goods_id', 'cloud_supplier_id', 'status', 'created_at', 'updated_at', 'is_delete'], 'integer']
+        ];
+    }
+
+}

+ 63 - 63
models/AgentGoodsInstallLog.php

@@ -1,63 +1,63 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%agent_goods_install_log}}".
- *
- * @property integer $id
- * @property integer $goods_agent_admin_id
- * @property integer $order_detail_id
- * @property integer $order_id
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $status
- * @property integer $is_need_install
- * @property integer $order_type
- */
-class AgentGoodsInstallLog extends \yii\db\ActiveRecord
-{
-    const ORDER_TYPE_NORMAL = 0;
-
-    const ORDER_TYPE_PURCHASE = 1;
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%agent_goods_install_log}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'goods_agent_admin_id', 'order_detail_id', 'created_at', 'updated_at', 'status', 'is_need_install', 'order_id', 'order_type'], 'integer']
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%agent_goods_install_log}}".
+ *
+ * @property integer $id
+ * @property integer $goods_agent_admin_id
+ * @property integer $order_detail_id
+ * @property integer $order_id
+ * @property integer $created_at
+ * @property integer $updated_at
+ * @property integer $status
+ * @property integer $is_need_install
+ * @property integer $order_type
+ */
+class AgentGoodsInstallLog extends \yii\db\ActiveRecord
+{
+    const ORDER_TYPE_NORMAL = 0;
+
+    const ORDER_TYPE_PURCHASE = 1;
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%agent_goods_install_log}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'goods_agent_admin_id', 'order_detail_id', 'created_at', 'updated_at', 'status', 'is_need_install', 'order_id', 'order_type'], 'integer']
+        ];
+    }
+
+}

+ 73 - 73
models/AggregateQrcode.php

@@ -1,74 +1,74 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-/**
- * This is the model class for table "{{%aggregate_qrcode}}".
- *
- * @property int    $id
- * @property int    $store_id
- * @property int    $wx_mini_id
- * @property int    $ali_mini_id
- * @property string $param_url
- * @property string $qrcode_url
- * @property int    $admin_id
- * @property int    $salesman_id
- * @property int    $is_use
- * @property string $wx_url
- * @property string $ali_url
- * @property string $create_time
- * @property int    $shop_bind_time
- * @property int    $mini_time
- * @property int    $audit_id
- * @property int    $ali_status
- * @property int    $wx_status
- */
-class AggregateQrcode extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%aggregate_qrcode}}';
-    }
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'store_id','wx_mini_id','ali_mini_id','admin_id','salesman_id','is_use','create_time',"shop_bind_time", "mini_time","audit_id","ali_status", "wx_status"], 'integer'],
-            [['param_url','qrcode_url','wx_url','ali_url'], 'string'],
-        ];
-    }
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' =>             "ID",
-            'store_id' =>       "商城ID",
-            'mini_id' =>        "小程序ID",
-            'param_url' =>      "访问链接",
-            'qrcode_url' =>     "二维码地址",
-            'admin_id' =>       "代理ID",
-            'salesman_id' =>    "业务员ID",
-            "is_use"=>          "使用状态",
-            "wx_url"=>          "微信小程序链接",
-            "ali_url"=>         "支付宝小程序链接",
-            "create_time"=>     "创建时间",
-            "shop_bind_time"=>  "商城绑定时间",
-            "mini_time"=>       "激活时间",
-            "wx_mini_id"=>      "微信小程序ID",
-            "ali_mini_id"=>     "支付宝小程序ID",
-            "audit_id"=>        "申请单ID",
-            "ali_status"=>      "支付宝绑定小程序状态",
-            "wx_status"=>       "微信绑定小程序状态",
-        ];
-    }
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+/**
+ * This is the model class for table "{{%aggregate_qrcode}}".
+ *
+ * @property int    $id
+ * @property int    $store_id
+ * @property int    $wx_mini_id
+ * @property int    $ali_mini_id
+ * @property string $param_url
+ * @property string $qrcode_url
+ * @property int    $admin_id
+ * @property int    $salesman_id
+ * @property int    $is_use
+ * @property string $wx_url
+ * @property string $ali_url
+ * @property string $create_time
+ * @property int    $shop_bind_time
+ * @property int    $mini_time
+ * @property int    $audit_id
+ * @property int    $ali_status
+ * @property int    $wx_status
+ */
+class AggregateQrcode extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%aggregate_qrcode}}';
+    }
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'store_id','wx_mini_id','ali_mini_id','admin_id','salesman_id','is_use','create_time',"shop_bind_time", "mini_time","audit_id","ali_status", "wx_status"], 'integer'],
+            [['param_url','qrcode_url','wx_url','ali_url'], 'string'],
+        ];
+    }
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' =>             "ID",
+            'store_id' =>       "商城ID",
+            'mini_id' =>        "小程序ID",
+            'param_url' =>      "访问链接",
+            'qrcode_url' =>     "二维码地址",
+            'admin_id' =>       "代理ID",
+            'salesman_id' =>    "业务员ID",
+            "is_use"=>          "使用状态",
+            "wx_url"=>          "微信小程序链接",
+            "ali_url"=>         "支付宝小程序链接",
+            "create_time"=>     "创建时间",
+            "shop_bind_time"=>  "商城绑定时间",
+            "mini_time"=>       "激活时间",
+            "wx_mini_id"=>      "微信小程序ID",
+            "ali_mini_id"=>     "支付宝小程序ID",
+            "audit_id"=>        "申请单ID",
+            "ali_status"=>      "支付宝绑定小程序状态",
+            "wx_status"=>       "微信绑定小程序状态",
+        ];
+    }
 }

+ 74 - 0
models/AggregateQrcodeNew.php

@@ -0,0 +1,74 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+/**
+ * This is the model class for table "{{%aggregate_qrcode}}".
+ *
+ * @property int    $id
+ * @property int    $store_id
+ * @property int    $wx_mini_id
+ * @property int    $ali_mini_id
+ * @property string $param_url
+ * @property string $qrcode_url
+ * @property int    $admin_id
+ * @property int    $salesman_id
+ * @property int    $is_use
+ * @property string $wx_url
+ * @property string $ali_url
+ * @property string $create_time
+ * @property int    $shop_bind_time
+ * @property int    $mini_time
+ * @property int    $audit_id
+ * @property int    $ali_status
+ * @property int    $wx_status
+ */
+class AggregateQrcodeNew extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%aggregate_qrcode_new}}';
+    }
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'store_id','wx_mini_id','ali_mini_id','admin_id','salesman_id','is_use','create_time',"shop_bind_time", "mini_time","audit_id","ali_status", "wx_status"], 'integer'],
+            [['param_url','qrcode_url','wx_url','ali_url'], 'string'],
+        ];
+    }
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' =>             "ID",
+            'store_id' =>       "商城ID",
+            'mini_id' =>        "小程序ID",
+            'param_url' =>      "访问链接",
+            'qrcode_url' =>     "二维码地址",
+            'admin_id' =>       "代理ID",
+            'salesman_id' =>    "业务员ID",
+            "is_use"=>          "使用状态",
+            "wx_url"=>          "微信小程序链接",
+            "ali_url"=>         "支付宝小程序链接",
+            "create_time"=>     "创建时间",
+            "shop_bind_time"=>  "商城绑定时间",
+            "mini_time"=>       "激活时间",
+            "wx_mini_id"=>      "微信小程序ID",
+            "ali_mini_id"=>     "支付宝小程序ID",
+            "audit_id"=>        "申请单ID",
+            "ali_status"=>      "支付宝绑定小程序状态",
+            "wx_status"=>       "微信绑定小程序状态",
+        ];
+    }
+}

+ 58 - 58
models/AggregateSaasQrcode.php

@@ -1,59 +1,59 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-/**
- * This is the model class for table "{{%aggregate_saas_qrcode}}".
- *
- * @property int    $id
- * @property int    $store_id
- * @property string $param_url
- * @property string $qrcode_url
- * @property int    $admin_id
- * @property int    $salesman_id
- * @property int    $is_use
- * @property string $mini_url
- * @property string $create_time
- * @property int    $shop_bind_time
- */
-class AggregateSaasQrcode extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%aggregate_saas_qrcode}}';
-    }
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [["id", "store_id", "admin_id", "salesman_id", "is_use", "create_time", "shop_bind_time"], 'integer'],
-            [["param_url", "qrcode_url", 'mini_url'], 'string'],
-        ];
-    }
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' =>             "ID",
-            'store_id' =>       "商城ID",
-            'param_url' =>      "访问链接",
-            'qrcode_url' =>     "二维码地址",
-            'admin_id' =>       "代理ID",
-            'salesman_id' =>    "业务员ID",
-            "is_use"=>          "使用状态",
-            "mini_url"=>         "小程序链接",
-            "create_time"=>     "创建时间",
-            "shop_bind_time"=>  "商城绑定时间"
-        ];
-    }
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+/**
+ * This is the model class for table "{{%aggregate_saas_qrcode}}".
+ *
+ * @property int    $id
+ * @property int    $store_id
+ * @property string $param_url
+ * @property string $qrcode_url
+ * @property int    $admin_id
+ * @property int    $salesman_id
+ * @property int    $is_use
+ * @property string $mini_url
+ * @property string $create_time
+ * @property int    $shop_bind_time
+ */
+class AggregateSaasQrcode extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%aggregate_saas_qrcode}}';
+    }
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [["id", "store_id", "admin_id", "salesman_id", "is_use", "create_time", "shop_bind_time"], 'integer'],
+            [["param_url", "qrcode_url", 'mini_url'], 'string'],
+        ];
+    }
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' =>             "ID",
+            'store_id' =>       "商城ID",
+            'param_url' =>      "访问链接",
+            'qrcode_url' =>     "二维码地址",
+            'admin_id' =>       "代理ID",
+            'salesman_id' =>    "业务员ID",
+            "is_use"=>          "使用状态",
+            "mini_url"=>         "小程序链接",
+            "create_time"=>     "创建时间",
+            "shop_bind_time"=>  "商城绑定时间"
+        ];
+    }
 }

+ 59 - 0
models/AggregateSaasQrcodeNew.php

@@ -0,0 +1,59 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+/**
+ * This is the model class for table "{{%aggregate_saas_qrcode}}".
+ *
+ * @property int    $id
+ * @property int    $store_id
+ * @property string $param_url
+ * @property string $qrcode_url
+ * @property int    $admin_id
+ * @property int    $salesman_id
+ * @property int    $is_use
+ * @property string $mini_url
+ * @property string $create_time
+ * @property int    $shop_bind_time
+ */
+class AggregateSaasQrcodeNew extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%aggregate_saas_qrcode_new}}';
+    }
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [["id", "store_id", "admin_id", "salesman_id", "is_use", "create_time", "shop_bind_time"], 'integer'],
+            [["param_url", "qrcode_url", 'mini_url'], 'string'],
+        ];
+    }
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' =>             "ID",
+            'store_id' =>       "商城ID",
+            'param_url' =>      "访问链接",
+            'qrcode_url' =>     "二维码地址",
+            'admin_id' =>       "代理ID",
+            'salesman_id' =>    "业务员ID",
+            "is_use"=>          "使用状态",
+            "mini_url"=>         "小程序链接",
+            "create_time"=>     "创建时间",
+            "shop_bind_time"=>  "商城绑定时间"
+        ];
+    }
+}

+ 54 - 54
models/AliMiniSign.php

@@ -1,55 +1,55 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-/**
- * This is the model class for table "{{%ali_mini_sign}}".
- *
- * @property int    $id
- * @property int    $type
- * @property string $batch_no
- * @property int    $batch_status
- * @property int    $ali_mini_id
- * @property string $fail_reason
- * @property string $batch_url
- * @property int    $app_type
- */
-class AliMiniSign extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%ali_mini_sign}}';
-    }
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [["id", "type", "batch_status", "ali_mini_id", 'app_type'], 'integer'],
-            [["batch_no", "fail_reason", "batch_url"], 'string'],
-        ];
-    }
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => "",
-            'type' => "类型  0当面付  1商家分账  2App支付",
-            'batch_no' => "编号",
-            'batch_status' => "事务状态 0未创建  1已经创建  2已签约 3审核中 4异常单 5 待确认 6确认成功 7超时未确认 8审核失败",
-            'ali_mini_id' => "",
-            'fail_reason' => "错误信息",
-            'batch_url' => "签约链接",
-            'app_type' => '支付宝应用类型 0小程序  1应用'
-        ];
-    }
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+/**
+ * This is the model class for table "{{%ali_mini_sign}}".
+ *
+ * @property int    $id
+ * @property int    $type
+ * @property string $batch_no
+ * @property int    $batch_status
+ * @property int    $ali_mini_id
+ * @property string $fail_reason
+ * @property string $batch_url
+ * @property int    $app_type
+ */
+class AliMiniSign extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%ali_mini_sign}}';
+    }
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [["id", "type", "batch_status", "ali_mini_id", 'app_type'], 'integer'],
+            [["batch_no", "fail_reason", "batch_url"], 'string'],
+        ];
+    }
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => "",
+            'type' => "类型  0当面付  1商家分账  2App支付",
+            'batch_no' => "编号",
+            'batch_status' => "事务状态 0未创建  1已经创建  2已签约 3审核中 4异常单 5 待确认 6确认成功 7超时未确认 8审核失败",
+            'ali_mini_id' => "",
+            'fail_reason' => "错误信息",
+            'batch_url' => "签约链接",
+            'app_type' => '支付宝应用类型 0小程序  1应用'
+        ];
+    }
 }

+ 172 - 172
models/AlipayAcitvityVoucherCoupon.php

@@ -1,173 +1,173 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-use app\models\WechatConfig;
-use app\models\Option;
-
-/**
- * This is the model class for table "{{%coupon}}".
- *
- * @property int $id
- * @property int $mini_id
- * @property int $status
- * @property string $alipay_activity_id
- * @property datetime $publish_start_time
- * @property datetime $publish_end_time
- * @property int $store_id
- * @property string $name 优惠券名称
- * @property string $desc 优惠券描述
- * @property string|null $pic_url 缩略图
- * @property int $discount_type 优惠券类型:1=折扣,2=满减
- * @property float $min_price 最低消费金额
- * @property float $sub_price 优惠金额
- * @property float $discount 折扣率
- * @property int $expire_type 到期类型:1=领取后N天过期,2=指定有效期
- * @property int $expire_day 有效天数,expire_type=1时
- * @property int $begin_time 有效期开始时间
- * @property int $end_time 有效期结束时间
- * @property int $created_at 添加时间
- * @property int $is_delete 是否删除
- * @property int $total_count 发放总数量
- * @property int $is_join 是否加入领券中心 1--不加入领券中心 2--加入领券中心
- * @property int $is_alipay_voucher
- * @property int|null $sort 排序按升序排列
- * @property string|null $cat_id_list
- * @property int|null $appoint_type
- * @property int $is_integral 是否加入积分商城 1--不加入 2--加入
- * @property int $integral 兑换需要积分数量
- * @property float $price 售价
- * @property int $total_num 积分商城发放总数
- * @property int $user_num 每人限制兑换数量
- * @property string|null $rule 使用说明
- * @property string|null $goods_id_list
- * @property int|null $mch_id 入驻商id
- * @property int|null $updated_at
- * @property int $is_join_welfare 是否加入到福利中心
- * @property int $is_give
- */
-class AlipayAcitvityVoucherCoupon extends \yii\db\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%alipay_activity_voucher_coupon}}';
-    }
-
-
-    const IS_DELETE_YES = 1;//已删除
-    const IS_DELETE_NO = 0;//未删除
-    const IS_JOIN_YES = 2; //加入领券中心
-    const IS_JOIN_NO = 1;//不加入领券中心
-    const DISCOUNT_TYPE_ONE = 1;//折扣类型
-    const DISCOUNT_TYPE_TWO = 2; //满减类型
-    const EXPIRE_TYPE_DAY = 1;//领取后n天过期
-    const EXPIRE_TYPE_DATE = 2;//指定有效期
-    const IS_INTEGRAL_YES = 2;//加入积分商城
-    const IS_INTEGRAL_NO = 1;//不加入积分商城
-    const APPOINT_TYPE_CAT = 1;//商品分类
-    const APPOINT_TYPE_GOODS = 2;//商品
-    const APPOINT_TYPE_FACE = 3;//当面付
-
-    /**
-     * saas 加入福利中心
-     */
-    const IS_JOIN_WELFARE_YES = 1;
-    /**
-     * saas 不加入福利中心
-     */
-    const IS_JOIN_WELFARE_NO = 0;
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'name'], 'required'],
-            [['store_id', 'discount_type', 'updated_at', 'expire_type', 'expire_day', 'begin_time', 'end_time', 'created_at', 'is_delete', 'total_count', 'is_join', 'sort', 'appoint_type', 'is_integral', 'integral', 'total_num', 'user_num', 'mch_id', 'is_join_welfare', 'is_give','is_business','business_type','is_alipay_voucher'], 'integer'],
-            [['min_price', 'sub_price', 'discount', 'price'], 'number'],
-            [['name', 'cat_id_list', 'goods_id_list'], 'string', 'max' => 255],
-            [['desc'], 'string', 'max' => 2000],
-            [['pic_url'], 'string', 'max' => 2048],
-            [['rule'], 'string', 'max' => 1000],
-            ['discount', 'default', 'value' => 10],
-            ['is_integral', 'default', 'value' => 1],
-            ['integral', 'default', 'value' => 0],
-            ['price', 'default', 'value' => 0],
-            ['total_num', 'default', 'value' => 0],
-            ['expire_day', 'default', 'value' => 0],
-            ['user_num', 'default', 'value' => 0],
-            ['sub_price', 'default', 'value' => 0],
-            ['total_count', 'default', 'value' => -1],
-            [['begin_time', 'end_time'], 'default', 'value' => 0],
-            [['is_alipay_voucher', 'mini_id', 'publish_start_time', 'publish_end_time', 'alipay_activity_id', 'status'], 'safe']
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => 'Store ID',
-            'name' => '优惠券名称',
-            'desc' => '优惠券描述',
-            'pic_url' => '缩略图',
-            'discount_type' => '优惠券类型:1=折扣,2=满减',
-            'min_price' => '最低消费金额',
-            'sub_price' => '优惠金额',
-            'discount' => '折扣率',
-            'expire_type' => '到期类型:1=领取后N天过期,2=指定有效期',
-            'expire_day' => '有效天数,expire_type=1时',
-            'begin_time' => '有效期开始时间',
-            'end_time' => '有效期结束时间',
-            'created_at' => '添加时间',
-            'is_delete' => '是否删除',
-            'total_count' => '发放总数量',
-            'is_join' => '是否加入领券中心 1--不加入领券中心 2--加入领券中心',
-            'sort' => '排序按降序排列',
-            'cat_id_list' => 'Cat Id List',
-            'appoint_type' => 'Appoint Type',
-            'is_integral' => '是否加入积分商城 1--不加入 2--加入',
-            'integral' => '兑换需要积分数量',
-            'price' => '售价',
-            'total_num' => '积分商城发放总数',
-            'user_num' => '每人限制兑换数量',
-            'rule' => '使用说明',
-            'goods_id_list' => 'Goods Id List',
-            'mch_id' => '入驻商id',
-            'updated_at' => 'Update Time',
-            'is_join_welfare' => '是否加入福利中心 1--不加入福利中心 2--加入福利中心',
-            'is_give' => '是否可转增',
-            'is_business' => '是否是商盟',
-            'business_type' => '展示位置',
-        ];
-    }
-
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+use app\models\WechatConfig;
+use app\models\Option;
+
+/**
+ * This is the model class for table "{{%coupon}}".
+ *
+ * @property int $id
+ * @property int $mini_id
+ * @property int $status
+ * @property string $alipay_activity_id
+ * @property datetime $publish_start_time
+ * @property datetime $publish_end_time
+ * @property int $store_id
+ * @property string $name 优惠券名称
+ * @property string $desc 优惠券描述
+ * @property string|null $pic_url 缩略图
+ * @property int $discount_type 优惠券类型:1=折扣,2=满减
+ * @property float $min_price 最低消费金额
+ * @property float $sub_price 优惠金额
+ * @property float $discount 折扣率
+ * @property int $expire_type 到期类型:1=领取后N天过期,2=指定有效期
+ * @property int $expire_day 有效天数,expire_type=1时
+ * @property int $begin_time 有效期开始时间
+ * @property int $end_time 有效期结束时间
+ * @property int $created_at 添加时间
+ * @property int $is_delete 是否删除
+ * @property int $total_count 发放总数量
+ * @property int $is_join 是否加入领券中心 1--不加入领券中心 2--加入领券中心
+ * @property int $is_alipay_voucher
+ * @property int|null $sort 排序按升序排列
+ * @property string|null $cat_id_list
+ * @property int|null $appoint_type
+ * @property int $is_integral 是否加入积分商城 1--不加入 2--加入
+ * @property int $integral 兑换需要积分数量
+ * @property float $price 售价
+ * @property int $total_num 积分商城发放总数
+ * @property int $user_num 每人限制兑换数量
+ * @property string|null $rule 使用说明
+ * @property string|null $goods_id_list
+ * @property int|null $mch_id 入驻商id
+ * @property int|null $updated_at
+ * @property int $is_join_welfare 是否加入到福利中心
+ * @property int $is_give
+ */
+class AlipayAcitvityVoucherCoupon extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%alipay_activity_voucher_coupon}}';
+    }
+
+
+    const IS_DELETE_YES = 1;//已删除
+    const IS_DELETE_NO = 0;//未删除
+    const IS_JOIN_YES = 2; //加入领券中心
+    const IS_JOIN_NO = 1;//不加入领券中心
+    const DISCOUNT_TYPE_ONE = 1;//折扣类型
+    const DISCOUNT_TYPE_TWO = 2; //满减类型
+    const EXPIRE_TYPE_DAY = 1;//领取后n天过期
+    const EXPIRE_TYPE_DATE = 2;//指定有效期
+    const IS_INTEGRAL_YES = 2;//加入积分商城
+    const IS_INTEGRAL_NO = 1;//不加入积分商城
+    const APPOINT_TYPE_CAT = 1;//商品分类
+    const APPOINT_TYPE_GOODS = 2;//商品
+    const APPOINT_TYPE_FACE = 3;//当面付
+
+    /**
+     * saas 加入福利中心
+     */
+    const IS_JOIN_WELFARE_YES = 1;
+    /**
+     * saas 不加入福利中心
+     */
+    const IS_JOIN_WELFARE_NO = 0;
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'name'], 'required'],
+            [['store_id', 'discount_type', 'updated_at', 'expire_type', 'expire_day', 'begin_time', 'end_time', 'created_at', 'is_delete', 'total_count', 'is_join', 'sort', 'appoint_type', 'is_integral', 'integral', 'total_num', 'user_num', 'mch_id', 'is_join_welfare', 'is_give','is_business','business_type','is_alipay_voucher'], 'integer'],
+            [['min_price', 'sub_price', 'discount', 'price'], 'number'],
+            [['name', 'cat_id_list', 'goods_id_list'], 'string', 'max' => 255],
+            [['desc'], 'string', 'max' => 2000],
+            [['pic_url'], 'string', 'max' => 2048],
+            [['rule'], 'string', 'max' => 1000],
+            ['discount', 'default', 'value' => 10],
+            ['is_integral', 'default', 'value' => 1],
+            ['integral', 'default', 'value' => 0],
+            ['price', 'default', 'value' => 0],
+            ['total_num', 'default', 'value' => 0],
+            ['expire_day', 'default', 'value' => 0],
+            ['user_num', 'default', 'value' => 0],
+            ['sub_price', 'default', 'value' => 0],
+            ['total_count', 'default', 'value' => -1],
+            [['begin_time', 'end_time'], 'default', 'value' => 0],
+            [['is_alipay_voucher', 'mini_id', 'publish_start_time', 'publish_end_time', 'alipay_activity_id', 'status'], 'safe']
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID',
+            'name' => '优惠券名称',
+            'desc' => '优惠券描述',
+            'pic_url' => '缩略图',
+            'discount_type' => '优惠券类型:1=折扣,2=满减',
+            'min_price' => '最低消费金额',
+            'sub_price' => '优惠金额',
+            'discount' => '折扣率',
+            'expire_type' => '到期类型:1=领取后N天过期,2=指定有效期',
+            'expire_day' => '有效天数,expire_type=1时',
+            'begin_time' => '有效期开始时间',
+            'end_time' => '有效期结束时间',
+            'created_at' => '添加时间',
+            'is_delete' => '是否删除',
+            'total_count' => '发放总数量',
+            'is_join' => '是否加入领券中心 1--不加入领券中心 2--加入领券中心',
+            'sort' => '排序按降序排列',
+            'cat_id_list' => 'Cat Id List',
+            'appoint_type' => 'Appoint Type',
+            'is_integral' => '是否加入积分商城 1--不加入 2--加入',
+            'integral' => '兑换需要积分数量',
+            'price' => '售价',
+            'total_num' => '积分商城发放总数',
+            'user_num' => '每人限制兑换数量',
+            'rule' => '使用说明',
+            'goods_id_list' => 'Goods Id List',
+            'mch_id' => '入驻商id',
+            'updated_at' => 'Update Time',
+            'is_join_welfare' => '是否加入福利中心 1--不加入福利中心 2--加入福利中心',
+            'is_give' => '是否可转增',
+            'is_business' => '是否是商盟',
+            'business_type' => '展示位置',
+        ];
+    }
+
 }

+ 136 - 136
models/AlipayAcitvityVoucherOrder.php

@@ -1,137 +1,137 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-use app\models\WechatConfig;
-use app\models\Option;
-use \app\models\AlipayAcitvityVoucherCoupon;
-
-/**
- * This is the model class for table "{{%coupon}}".
- *
- * @property int $id
- * @property int $alipay_activity_id
- * @property int $mini_id
- * @property string $event_time
- * @property string $voucher_id
- * @property string $user_id
- * @property string $trade_no
- * @property int $store_id
- * @property int $created_at 添加时间
- * @property int $is_delete 是否删除
- * @property int|null $mch_id 入驻商id
- * @property int|null $updated_at
- */
-class AlipayAcitvityVoucherOrder extends \yii\db\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%alipay_activity_voucher_order}}';
-    }
-
-
-    const IS_DELETE_YES = 1;//已删除
-    const IS_DELETE_NO = 0;//未删除
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['notify_id', 'alipay_activity_id', 'event_time', 'voucher_id', 'user_id', 'trade_no'], 'required'],
-            [['store_id', 'mini_id', 'mch_id', 'created_at', 'is_delete', 'updated_at'], 'safe']
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => 'Store ID',
-            'notify_id' => '事件id。可用于业务去重。',
-            'alipay_activity_id' => '支付宝支付券活动id',
-            'mini_id' => 'mini_id',
-            'event_time' => '事件创建时间',
-            'voucher_id' => '支付宝券ID',
-            'user_id' => '支付宝user_id账号',
-            'trade_no' => '核销交易订单号',
-            'created_at' => '添加时间',
-            'is_delete' => '是否删除',
-            'mch_id' => '入驻商id',
-            'updated_at' => 'Update Time',
-        ];
-    }
-    
-    public function beforeSave($insert) {
-        if(!parent::beforeSave($insert)){
-            return false;
-        }
-        if($insert){
-            $coupon = AlipayAcitvityVoucherCoupon::findOne(['alipay_activity_id' => $this->alipay_activity_id]);
-            if(!$coupon){
-                $this->addError('alipay_activity_id', '未找到支付券活动');
-                return false;
-            }
-            $this->store_id = $coupon->store_id;
-            $this->mini_id = $coupon->mini_id;
-            $this->mch_id = $coupon->mch_id;
-        }
-        return true;
-    }
-    
-    public static function usedNotify($biz = []) {
-        $model = self::findOne(['notify_id' => $biz['id']]);
-        if($model){
-            return true;
-        }
-        $model = new self();
-        $model->notify_id = $biz['id'];
-        $model->alipay_activity_id = $biz['activity_id'];
-        $model->event_time = substr($biz['event_time'], 0, 10);
-        $model->voucher_id = $biz['voucher_id'];
-        $model->user_id = $biz['user_id'];
-        $model->trade_no = $biz['trade_no'];
-        $save = $model->save();
-        if(!$save){
-            \Yii::error([__METHOD__, $biz, $model->errors]);
-            return false;
-        }
-        return true;
-    }
-    
-    public static function getByOrder($trade_no) {
-        $model = self::findOne(['trade_no' => $trade_no]);
-        if($model){
-            $coupon = AlipayAcitvityVoucherCoupon::findOne(['alipay_activity_id' => $model->alipay_activity_id]);
-            return $coupon;
-        }
-    }
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+use app\models\WechatConfig;
+use app\models\Option;
+use \app\models\AlipayAcitvityVoucherCoupon;
+
+/**
+ * This is the model class for table "{{%coupon}}".
+ *
+ * @property int $id
+ * @property int $alipay_activity_id
+ * @property int $mini_id
+ * @property string $event_time
+ * @property string $voucher_id
+ * @property string $user_id
+ * @property string $trade_no
+ * @property int $store_id
+ * @property int $created_at 添加时间
+ * @property int $is_delete 是否删除
+ * @property int|null $mch_id 入驻商id
+ * @property int|null $updated_at
+ */
+class AlipayAcitvityVoucherOrder extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%alipay_activity_voucher_order}}';
+    }
+
+
+    const IS_DELETE_YES = 1;//已删除
+    const IS_DELETE_NO = 0;//未删除
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['notify_id', 'alipay_activity_id', 'event_time', 'voucher_id', 'user_id', 'trade_no'], 'required'],
+            [['store_id', 'mini_id', 'mch_id', 'created_at', 'is_delete', 'updated_at'], 'safe']
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID',
+            'notify_id' => '事件id。可用于业务去重。',
+            'alipay_activity_id' => '支付宝支付券活动id',
+            'mini_id' => 'mini_id',
+            'event_time' => '事件创建时间',
+            'voucher_id' => '支付宝券ID',
+            'user_id' => '支付宝user_id账号',
+            'trade_no' => '核销交易订单号',
+            'created_at' => '添加时间',
+            'is_delete' => '是否删除',
+            'mch_id' => '入驻商id',
+            'updated_at' => 'Update Time',
+        ];
+    }
+    
+    public function beforeSave($insert) {
+        if(!parent::beforeSave($insert)){
+            return false;
+        }
+        if($insert){
+            $coupon = AlipayAcitvityVoucherCoupon::findOne(['alipay_activity_id' => $this->alipay_activity_id]);
+            if(!$coupon){
+                $this->addError('alipay_activity_id', '未找到支付券活动');
+                return false;
+            }
+            $this->store_id = $coupon->store_id;
+            $this->mini_id = $coupon->mini_id;
+            $this->mch_id = $coupon->mch_id;
+        }
+        return true;
+    }
+    
+    public static function usedNotify($biz = []) {
+        $model = self::findOne(['notify_id' => $biz['id']]);
+        if($model){
+            return true;
+        }
+        $model = new self();
+        $model->notify_id = $biz['id'];
+        $model->alipay_activity_id = $biz['activity_id'];
+        $model->event_time = substr($biz['event_time'], 0, 10);
+        $model->voucher_id = $biz['voucher_id'];
+        $model->user_id = $biz['user_id'];
+        $model->trade_no = $biz['trade_no'];
+        $save = $model->save();
+        if(!$save){
+            \Yii::error([__METHOD__, $biz, $model->errors]);
+            return false;
+        }
+        return true;
+    }
+    
+    public static function getByOrder($trade_no) {
+        $model = self::findOne(['trade_no' => $trade_no]);
+        if($model){
+            $coupon = AlipayAcitvityVoucherCoupon::findOne(['alipay_activity_id' => $model->alipay_activity_id]);
+            return $coupon;
+        }
+    }
 }

+ 85 - 85
models/AlipayActivityDelivery.php

@@ -1,86 +1,86 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-/**
- * This is the model class for table "{{%alipay_activity_delivery}}".
- *
- * @property int $id
- * @property int $mini_id 小程序id
- * @property int $store_id 商城id
- * @property string $delivery_name 推广计划活动名称
- * @property int $delivery_begin_time 开始时间
- * @property int $delivery_end_time 结束时间
- * @property int $delivery_booth_code 展位编码 1日常推广 2支付页面
- * @property int $type 0支付送 1满额送
- * @property string $order_no 外部订单号
- * @property int $voucher_activity_id 商家券活动id
- * @property int $delivery_floor_amount 满额送门槛金额
- * @property string $useid 收款账户
- * @property int $created_at 创建时间
- * @property int $update_at 修改时间
- * @property int $unable_at 禁用时间
- * @property int $is_delete 是否删除
- * @property string $delivery_id 支付宝推广活动id
- * @property int $status 状态 1:生效中 2:已失效 0:审核中 3:审核不通过。
- * @property string $fail_reason 失败原因
- * @property string $delivery_image 单素材图片支付宝素材库id
- * @property string $delivery_image_url 单素材图片本地地址
- */
-class AlipayActivityDelivery extends \yii\db\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%alipay_activity_delivery}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'mini_id', 'store_id', 'delivery_begin_time', 'delivery_end_time', 'delivery_booth_code', 'type', 'voucher_activity_id', 'update_at', 'unable_at', 'is_delete', 'created_at', 'status'], 'integer'],
-            [["delivery_name", "order_no", "useid", 'delivery_id', 'fail_reason', 'delivery_image', 'delivery_image_url'], 'string'],
-            [['delivery_floor_amount'], 'number'],
-            [['delivery_name'], 'string', 'max' => 20],
-            [['delivery_name'], 'string', 'min' => 3],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => '',
-            'mini_id' => '小程序id',
-            'store_id' => '商城id',
-            'delivery_name' => '推广计划活动名称',
-            'delivery_begin_time' => '开始时间',
-            'delivery_end_time' => '结束时间',
-            'delivery_booth_code' => '展位编码 1日常推广 2支付页面',
-            'type' => '0支付送 1满额送',
-            'order_no' => '外部订单号',
-            'voucher_activity_id' => '商家券活动id',
-            'delivery_floor_amount' => '满额送门槛金额',
-            'useid' => '收款账户',
-            'created_at' => '创建时间',
-            'update_at' => '修改时间',
-            'unable_at' => '禁用时间',
-            'is_delete' => '是否删除',
-            'delivery_id' => '支付宝推广活动id',
-            'status' => '1:生效中 2:已失效 0:审核中 3:审核不通过。',
-            'fail_reason' => '失败原因',
-            'delivery_image' => '单素材图片支付宝素材库id',
-            'delivery_image_url' => '单素材图片本地地址',
-        ];
-    }
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+/**
+ * This is the model class for table "{{%alipay_activity_delivery}}".
+ *
+ * @property int $id
+ * @property int $mini_id 小程序id
+ * @property int $store_id 商城id
+ * @property string $delivery_name 推广计划活动名称
+ * @property int $delivery_begin_time 开始时间
+ * @property int $delivery_end_time 结束时间
+ * @property int $delivery_booth_code 展位编码 1日常推广 2支付页面
+ * @property int $type 0支付送 1满额送
+ * @property string $order_no 外部订单号
+ * @property int $voucher_activity_id 商家券活动id
+ * @property int $delivery_floor_amount 满额送门槛金额
+ * @property string $useid 收款账户
+ * @property int $created_at 创建时间
+ * @property int $update_at 修改时间
+ * @property int $unable_at 禁用时间
+ * @property int $is_delete 是否删除
+ * @property string $delivery_id 支付宝推广活动id
+ * @property int $status 状态 1:生效中 2:已失效 0:审核中 3:审核不通过。
+ * @property string $fail_reason 失败原因
+ * @property string $delivery_image 单素材图片支付宝素材库id
+ * @property string $delivery_image_url 单素材图片本地地址
+ */
+class AlipayActivityDelivery extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%alipay_activity_delivery}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'mini_id', 'store_id', 'delivery_begin_time', 'delivery_end_time', 'delivery_booth_code', 'type', 'voucher_activity_id', 'update_at', 'unable_at', 'is_delete', 'created_at', 'status'], 'integer'],
+            [["delivery_name", "order_no", "useid", 'delivery_id', 'fail_reason', 'delivery_image', 'delivery_image_url'], 'string'],
+            [['delivery_floor_amount'], 'number'],
+            [['delivery_name'], 'string', 'max' => 20],
+            [['delivery_name'], 'string', 'min' => 3],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => '',
+            'mini_id' => '小程序id',
+            'store_id' => '商城id',
+            'delivery_name' => '推广计划活动名称',
+            'delivery_begin_time' => '开始时间',
+            'delivery_end_time' => '结束时间',
+            'delivery_booth_code' => '展位编码 1日常推广 2支付页面',
+            'type' => '0支付送 1满额送',
+            'order_no' => '外部订单号',
+            'voucher_activity_id' => '商家券活动id',
+            'delivery_floor_amount' => '满额送门槛金额',
+            'useid' => '收款账户',
+            'created_at' => '创建时间',
+            'update_at' => '修改时间',
+            'unable_at' => '禁用时间',
+            'is_delete' => '是否删除',
+            'delivery_id' => '支付宝推广活动id',
+            'status' => '1:生效中 2:已失效 0:审核中 3:审核不通过。',
+            'fail_reason' => '失败原因',
+            'delivery_image' => '单素材图片支付宝素材库id',
+            'delivery_image_url' => '单素材图片本地地址',
+        ];
+    }
 }

+ 41 - 41
models/AlipayCard.php

@@ -1,41 +1,41 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%alipay_card}}".
- *
- * @property integer $id
- */
-class AlipayCard extends \yii\db\ActiveRecord
-{
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%alipay_card}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
-                ]
-            ]
-        ];
-    }
-    
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%alipay_card}}".
+ *
+ * @property integer $id
+ */
+class AlipayCard extends \yii\db\ActiveRecord
+{
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%alipay_card}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                ]
+            ]
+        ];
+    }
+    
+}

+ 41 - 41
models/AlipayCardTemp.php

@@ -1,41 +1,41 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%alipay_card_temp}}".
- *
- * @property integer $id
- */
-class AlipayCardTemp extends \yii\db\ActiveRecord
-{
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%alipay_card_temp}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
-                ]
-            ]
-        ];
-    }
-    
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%alipay_card_temp}}".
+ *
+ * @property integer $id
+ */
+class AlipayCardTemp extends \yii\db\ActiveRecord
+{
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%alipay_card_temp}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                ]
+            ]
+        ];
+    }
+    
+}

+ 54 - 54
models/AlipayMarketingMaterial.php

@@ -1,54 +1,54 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-class AlipayMarketingMaterial extends ActiveRecord
-{
-
-
-    public static function tableName()
-    {
-        return '{{%alipay_marketing_material}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                // 自动更新创建和更新时间
-                'class' => TimestampBehavior::class,
-                'value' => null
-            ]
-        ];
-    }
-
-    public function rules()
-    {
-        return [
-            [['id', 'material_id', 'store_id', 'mini_id'], 'integer'],
-            [['create_at', 'update_at', 'is_delete', 'material_name', 'info_json'], 'safe']
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'mini_id' => 'store_id',
-            'store_id' => 'store_id',
-            'material_id' => '素材id',
-            'material_name' => '素材名称',
-            'info_json' => '素材详情',
-            'is_delete' => '删除',
-            'create_at' => '创建时间',
-            'update_at' => '更新时间',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+class AlipayMarketingMaterial extends ActiveRecord
+{
+
+
+    public static function tableName()
+    {
+        return '{{%alipay_marketing_material}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                // 自动更新创建和更新时间
+                'class' => TimestampBehavior::class,
+                'value' => null
+            ]
+        ];
+    }
+
+    public function rules()
+    {
+        return [
+            [['id', 'material_id', 'store_id', 'mini_id'], 'integer'],
+            [['create_at', 'update_at', 'is_delete', 'material_name', 'info_json'], 'safe']
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'mini_id' => 'store_id',
+            'store_id' => 'store_id',
+            'material_id' => '素材id',
+            'material_name' => '素材名称',
+            'info_json' => '素材详情',
+            'is_delete' => '删除',
+            'create_at' => '创建时间',
+            'update_at' => '更新时间',
+        ];
+    }
+}

+ 162 - 162
models/AlipaySharingReceiver.php

@@ -1,162 +1,162 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-use Yii;
-
-/**
- * This is the model class for table "{{%alipay_sharing_receiver}}".
- *
- * @property int $id
- * @property int $store_id
- * @property string $order_no 订单号
- * @property int $type 接收方类型
- * @property int $user_id 接收方类型
- * @property string $account 分账接收方账户
- * @property string $name 分账接收方名称
- * @property string $description 分账原因描述
- * @property int $is_delete
- * @property int $amount
- * @property int $rate
- * @property int $from
- * @property string $err_code
- * @property string $err_code_des
- * @property int $is_pay
- * @property string $remark
- * @property int $created_at
- * @property int $updated_at
- */
-class AlipaySharingReceiver extends \yii\db\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%alipay_sharing_receiver}}';
-    }
-
-    const IS_DELETE_YES = 1;// 已删除
-    const IS_DELETE_NO = 0;// 未删除
-
-
-    /**
-     * 支付结果类型:未分账
-     */
-    const PAY_WAIT = 0;
-    /**
-     * 支付结果类型:已分账
-     */
-    const PAY_SUCCESS = 1;
-    /**
-     * 支付结果类型:分账失败
-     */
-    const PAY_FAIL = 2;
-
-
-    /**
-     * 接收方类型:USER_ID
-     */
-    const RECEIVE_USER_ID = 1;
-    /**
-     * 接收方类型:LOGIN_NAME
-     */
-    const RECEIVE_LOGIN_NAME = 2;
-
-
-    public static $validReceiveType = [
-        self::RECEIVE_USER_ID => 'userId',
-        self::RECEIVE_LOGIN_NAME => 'loginName'
-    ];
-
-    /**
-     * 分账来源类型: 商城
-     */
-    const FROM_STORE = 0;
-    /**
-     * 分账来源类型: 平台
-     */
-    const FROM_PLATFORM = 1;
-
-    /**
-     * 分账来源类型: 推荐
-     */
-    const FROM_RECOMMEND = 2;
-
-    /**
-     * 分账来源类型: 服务商
-     */
-    const FROM_SERVICE_PROVIDER = 3;
-
-    /**
-     * 分账来源类型: 商城间分销
-     */
-    const FROM_STORE_TO_STORE = 4;
-
-    public static $validNewFrom = [
-        self::FROM_STORE,
-        self::FROM_RECOMMEND,
-        self::FROM_SERVICE_PROVIDER,
-        self::FROM_PLATFORM,
-        self::FROM_STORE_TO_STORE
-    ];
-
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'is_delete', 'created_at', 'updated_at', 'type', 'is_pay', 'from', 'user_id'], 'integer'],
-            [['amount', 'rate'], 'number'],
-            [['name', 'description', 'account', 'order_no', 'err_code', 'err_code_des', 'remark'], 'string', 'max' => 255],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => 'Store ID',
-            'name' => '接收方姓名',
-            'type' => '分账接收方类型,1:user_id 1:login_name',
-            'description' => '分账描述',
-            'user_id' => 'USER ID',
-            'account' => '分账接收方账户',
-            'order_no' => '订单号',
-            'is_pay' => '是否支付',
-            'amount' => '金额',
-            'rate' => '比例',
-            'from' => '0:店铺分销,1:saas平台分销, 2:推荐分账,3:服务商分账 4:商城级分账',
-            'err_code' => '分账错误代码',
-            'err_code_des' => '分账错误信息',
-            'remark' => '标注类型,例如:店铺分销',
-            'is_delete' => 'Is Delete',
-            'created_at' => 'Add Time',
-            'updated_at' => 'Update Time',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+use Yii;
+
+/**
+ * This is the model class for table "{{%alipay_sharing_receiver}}".
+ *
+ * @property int $id
+ * @property int $store_id
+ * @property string $order_no 订单号
+ * @property int $type 接收方类型
+ * @property int $user_id 接收方类型
+ * @property string $account 分账接收方账户
+ * @property string $name 分账接收方名称
+ * @property string $description 分账原因描述
+ * @property int $is_delete
+ * @property int $amount
+ * @property int $rate
+ * @property int $from
+ * @property string $err_code
+ * @property string $err_code_des
+ * @property int $is_pay
+ * @property string $remark
+ * @property int $created_at
+ * @property int $updated_at
+ */
+class AlipaySharingReceiver extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%alipay_sharing_receiver}}';
+    }
+
+    const IS_DELETE_YES = 1;// 已删除
+    const IS_DELETE_NO = 0;// 未删除
+
+
+    /**
+     * 支付结果类型:未分账
+     */
+    const PAY_WAIT = 0;
+    /**
+     * 支付结果类型:已分账
+     */
+    const PAY_SUCCESS = 1;
+    /**
+     * 支付结果类型:分账失败
+     */
+    const PAY_FAIL = 2;
+
+
+    /**
+     * 接收方类型:USER_ID
+     */
+    const RECEIVE_USER_ID = 1;
+    /**
+     * 接收方类型:LOGIN_NAME
+     */
+    const RECEIVE_LOGIN_NAME = 2;
+
+
+    public static $validReceiveType = [
+        self::RECEIVE_USER_ID => 'userId',
+        self::RECEIVE_LOGIN_NAME => 'loginName'
+    ];
+
+    /**
+     * 分账来源类型: 商城
+     */
+    const FROM_STORE = 0;
+    /**
+     * 分账来源类型: 平台
+     */
+    const FROM_PLATFORM = 1;
+
+    /**
+     * 分账来源类型: 推荐
+     */
+    const FROM_RECOMMEND = 2;
+
+    /**
+     * 分账来源类型: 服务商
+     */
+    const FROM_SERVICE_PROVIDER = 3;
+
+    /**
+     * 分账来源类型: 商城间分销
+     */
+    const FROM_STORE_TO_STORE = 4;
+
+    public static $validNewFrom = [
+        self::FROM_STORE,
+        self::FROM_RECOMMEND,
+        self::FROM_SERVICE_PROVIDER,
+        self::FROM_PLATFORM,
+        self::FROM_STORE_TO_STORE
+    ];
+
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'is_delete', 'created_at', 'updated_at', 'type', 'is_pay', 'from', 'user_id'], 'integer'],
+            [['amount', 'rate'], 'number'],
+            [['name', 'description', 'account', 'order_no', 'err_code', 'err_code_des', 'remark'], 'string', 'max' => 255],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID',
+            'name' => '接收方姓名',
+            'type' => '分账接收方类型,1:user_id 1:login_name',
+            'description' => '分账描述',
+            'user_id' => 'USER ID',
+            'account' => '分账接收方账户',
+            'order_no' => '订单号',
+            'is_pay' => '是否支付',
+            'amount' => '金额',
+            'rate' => '比例',
+            'from' => '0:店铺分销,1:saas平台分销, 2:推荐分账,3:服务商分账 4:商城级分账',
+            'err_code' => '分账错误代码',
+            'err_code_des' => '分账错误信息',
+            'remark' => '标注类型,例如:店铺分销',
+            'is_delete' => 'Is Delete',
+            'created_at' => 'Add Time',
+            'updated_at' => 'Update Time',
+        ];
+    }
+}

+ 59 - 59
models/AlipayVoucherCode.php

@@ -1,59 +1,59 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-/**
- * This is the model class for table "{{%alipay_voucher_code}}".
- *
- * @property int $id
- * @property int $store_id
- * @property int $mini_id 小程序
- * @property int $activity_ordervoucher_id 商家券活动id
- * @property int $voucher_code 券码
- * @property int $status 券码
- * @property string $order_no 订单编号
- * @property string $clerk_saas_id
- * @property string $total_price
- * @property string $sub_price
- */
-
-class AlipayVoucherCode extends ActiveRecord
-{
-
-
-    public static function tableName()
-    {
-        return '{{%alipay_voucher_code}}';
-    }
-
-    public function rules()
-    {
-        return [
-            [['id', 'store_id', 'mini_id', 'activity_ordervoucher_id'], 'integer'],
-            [['create_at', 'update_at', 'is_delete', 'is_upload', 'clerk_saas_id', 'total_price', 'sub_price'], 'safe']
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'mini_id' => 'store_id',
-            'store_id' => 'store_id',
-            'activity_ordervoucher_id' => '商家券活动id',
-            'voucher_code' => '券码',
-            'status' => '状态',
-            'order_no' => '订单编号',
-            'clerk_saas_id' => 'clerk_saas_id',
-            'total_price' => 'total_price',
-            'sub_price' => 'sub_price',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+/**
+ * This is the model class for table "{{%alipay_voucher_code}}".
+ *
+ * @property int $id
+ * @property int $store_id
+ * @property int $mini_id 小程序
+ * @property int $activity_ordervoucher_id 商家券活动id
+ * @property int $voucher_code 券码
+ * @property int $status 券码
+ * @property string $order_no 订单编号
+ * @property string $clerk_saas_id
+ * @property string $total_price
+ * @property string $sub_price
+ */
+
+class AlipayVoucherCode extends ActiveRecord
+{
+
+
+    public static function tableName()
+    {
+        return '{{%alipay_voucher_code}}';
+    }
+
+    public function rules()
+    {
+        return [
+            [['id', 'store_id', 'mini_id', 'activity_ordervoucher_id'], 'integer'],
+            [['create_at', 'update_at', 'is_delete', 'is_upload', 'clerk_saas_id', 'total_price', 'sub_price'], 'safe']
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'mini_id' => 'store_id',
+            'store_id' => 'store_id',
+            'activity_ordervoucher_id' => '商家券活动id',
+            'voucher_code' => '券码',
+            'status' => '状态',
+            'order_no' => '订单编号',
+            'clerk_saas_id' => 'clerk_saas_id',
+            'total_price' => 'total_price',
+            'sub_price' => 'sub_price',
+        ];
+    }
+}

+ 53 - 53
models/AlipayVoucherCodeTask.php

@@ -1,53 +1,53 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-class AlipayVoucherCodeTask extends ActiveRecord
-{
-
-
-    public static function tableName()
-    {
-        return '{{%alipay_voucher_code_task}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                // 自动更新创建和更新时间
-                'class' => TimestampBehavior::class,
-                'value' => null
-            ]
-        ];
-    }
-
-    public function rules()
-    {
-        return [
-            [['id', 'store_id', 'mini_id', 'activity_ordervoucher_id'], 'integer'],
-            [['create_at', 'update_at', 'is_delete', 'is_upload'], 'safe']
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'mini_id' => 'store_id',
-            'store_id' => 'store_id',
-            'activity_ordervoucher_id' => '商家券活动id',
-            'is_upload' => '是否已上传',
-            'is_delete' => '删除',
-            'create_at' => '创建时间',
-            'update_at' => '更新时间',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+class AlipayVoucherCodeTask extends ActiveRecord
+{
+
+
+    public static function tableName()
+    {
+        return '{{%alipay_voucher_code_task}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                // 自动更新创建和更新时间
+                'class' => TimestampBehavior::class,
+                'value' => null
+            ]
+        ];
+    }
+
+    public function rules()
+    {
+        return [
+            [['id', 'store_id', 'mini_id', 'activity_ordervoucher_id'], 'integer'],
+            [['create_at', 'update_at', 'is_delete', 'is_upload'], 'safe']
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'mini_id' => 'store_id',
+            'store_id' => 'store_id',
+            'activity_ordervoucher_id' => '商家券活动id',
+            'is_upload' => '是否已上传',
+            'is_delete' => '删除',
+            'create_at' => '创建时间',
+            'update_at' => '更新时间',
+        ];
+    }
+}

+ 62 - 0
models/AllDistrictAgent.php

@@ -0,0 +1,62 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+
+namespace app\models;
+
+use app\plugins\scanCodePay\models\Order as ScanOrder;
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%all_district_agent}}".
+ *
+ * @property integer $id
+ * @property integer $divvy_id
+ * @property integer $saas_id
+ * @property integer $type
+ * @property double $dividend_amount
+ * @property integer $send_time
+ * @property integer $created_at
+ * @property integer $updated_at
+ */
+class AllDistrictAgent extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%all_district_agent}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['divvy_id', 'saas_id', 'send_time', 'type'], 'integer'],
+            [['dividend_amount'], 'number'],
+            [['created_at', 'updated_at'], 'safe']
+        ];
+    }
+}

+ 64 - 0
models/AllDistrictOrder.php

@@ -0,0 +1,64 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+
+namespace app\models;
+
+use app\plugins\scanCodePay\models\Order as ScanOrder;
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%all_district_order}}".
+ *
+ * @property integer $id
+ * @property integer $divvy_id
+ * @property string $order_no
+ * @property double $pay_price
+ * @property double $all_district_agent_divvy
+ * @property double $dividend_amount
+ * @property integer $send_time
+ * @property integer $created_at
+ * @property integer $updated_at
+ */
+class AllDistrictOrder extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%all_district_order}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['divvy_id', 'send_time'], 'integer'],
+            [['pay_price', 'dividend_amount', 'all_district_agent_divvy'], 'number'],
+            [['order_no'], 'string'],
+            [['created_at', 'updated_at'], 'safe']
+        ];
+    }
+}

+ 138 - 0
models/AllianceCouponSettle.php

@@ -0,0 +1,138 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+
+namespace app\models;
+
+
+use app\modules\admin\models\HuifuForm;
+use app\utils\OrderNo;
+use yii\db\Exception;
+
+/**
+ * This is the model class for table "{{%alliance_coupon_settle}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property string $price
+ * @property string $settle_no
+ * @property integer $settle_type
+ * @property integer $is_settle
+ * @property integer $unusually_condition
+ * @property string $unusually_msg
+ * @property integer $is_delete
+ * @property string $settled_at
+ * @property string $created_at
+ * @property string $updated_at
+ */
+class AllianceCouponSettle extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%alliance_coupon_settle}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['settle_type', 'store_id', 'unusually_condition', 'is_settle', 'is_delete'], 'integer'],
+            [['price'], 'number'],
+            [['updated_at', 'created_at', 'settled_at', 'settle_no', 'unusually_msg'], 'string'],
+        ];
+    }
+
+    public function beforeSave($insert)
+    {
+        if (parent::beforeSave($insert)) {
+            if ($this->isNewRecord) {
+                $this->created_at = date('Y-m-d H:i:s');
+            } else {
+                $this->updated_at = date('Y-m-d H:i:s');
+            }
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+        ];
+    }
+
+    public static function addAllianceCouponSettleLog($order, $order_type)
+    {
+        if (!in_array($order_type, [1, 2])) return false;
+        $store = Store::findOne($order->store_id);
+        if ($order->take_price <= 0 || $store->small_model_proportion >= 100) return false;
+        $settle_type = Option::get('alliance_coupon_settle_type', $order->store_id, 'store', 3)['value'];
+        $settle = null;
+        if ($settle_type != 0 && $settle_type != 1) {
+            $settle = AllianceCouponSettle::find()->where(['store_id' => $order->store_id, 'is_settle' => 0, 'is_delete' => 0])->one();
+        }
+        if (!$settle) {
+            $settle = new AllianceCouponSettle();
+            $settle->store_id = $order->store_id;
+            $settle->settle_no = OrderNo::getOrderNo(OrderNo::ALLIANCE_COUPON_SETTLE);
+            $settle->price = 0;
+        }
+        $price = $order->take_price * ($store->small_model_proportion / 100);
+        $add_price = $order->take_price - $price;
+        $settle->price += $add_price;
+        if (!$settle->save()) {
+            ActionLog::addLog(1, 'addAllianceCouponSettleLog', $settle->getErrorSummary(false)[0]);
+        }
+        $detail = new AllianceCouponSettleDetail();
+        $detail->order_id = $order->id;
+        $detail->store_id = $order->store_id;
+        $detail->price = $add_price;
+        $detail->take_price = $order->take_price;
+        $detail->rl_rate = $store->small_model_proportion;
+        $detail->order_type = $order_type;
+        $detail->settle_id = $settle->id;
+        if (!$detail->save()) {
+            ActionLog::addLog(1, 'addAllianceCouponSettleLog', $detail->getErrorSummary(false)[0]);
+        }
+        if ($settle_type == 1 && $detail->take_price > 0) {
+            $form = new HuifuForm();
+            $res = $form->actionHuifuyunpan($settle->id);
+            switch ($res['code']) {
+                case 0:
+                    $settle->settled_at = date('Y-m-d H:i:s');
+                    $settle->is_settle = 1;
+                    break;
+                case 1:
+                    $settle->unusually_condition = 1;
+                    $settle->unusually_msg = $res['msg'];
+                    break;
+                case 3:
+                    $settle->unusually_condition = 1;
+                    $settle->settle_type = 3;
+                    $settle->unusually_msg = $res['msg'];
+                    break;
+                default:
+                    $settle->unusually_condition = 1;
+                    $settle->settle_type = 3;
+                    $settle->unusually_msg = '打款状态不明,请检查是否打款成功';
+                    break;
+            }
+            if (!$settle->save()) {
+                ActionLog::addLog(1, 'addAllianceCouponSettleLog', $settle->getErrorSummary(false)[0]);
+            }
+        }
+        return true;
+    }
+}

+ 68 - 0
models/AllianceCouponSettleDetail.php

@@ -0,0 +1,68 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+
+/**
+ * This is the model class for table "{{%alliance_coupon_settle_detail}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $order_id
+ * @property integer $settle_id
+ * @property string  $price
+ * @property string  $take_price
+ * @property string  $rl_rate
+ * @property integer $order_type
+ * @property string $created_at
+ * @property string $updated_at
+ */
+class AllianceCouponSettleDetail extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%alliance_coupon_settle_detail}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [[ 'store_id','order_type','settle_id', 'order_id'], 'integer'],
+            [['price','take_price','rl_rate'], 'number'],
+            [['updated_at', 'created_at'], 'string'],
+        ];
+    }
+
+    public function beforeSave($insert)
+    {
+        if (parent::beforeSave($insert)) {
+            if ($this->isNewRecord) {
+                $this->created_at = date('Y-m-d H:i:s');
+            }else{
+                $this->updated_at = date('Y-m-d H:i:s');
+            }
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+        ];
+    }
+}

+ 133 - 133
models/AppNavbar.php

@@ -1,133 +1,133 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\helpers\Json;
-
-class AppNavbar
-{
-    /**
-     * @return array
-     */
-    public static function getNavbar($store_id)
-    {
-        $default_navbar = [
-            'background_image' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX///+nxBvIAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==',
-            'border_color' => '#ffffff',
-            'navs' => [
-                [
-                    'url' => '/pages/index/index',
-                    'base_url' => '/pages/index/index',
-                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-index.png',
-                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-index.active.png',
-                    'text' => '商城',
-                    'color' => '#888',
-                    'active_color' => '#ff4544',
-                ],
-                [
-                    'url' => '/pages/cat/cat',
-                    'base_url' => '/pages/cat/cat',
-                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-cat.png',
-                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-cat.active.png',
-                    'text' => '分类',
-                    'color' => '#888',
-                    'active_color' => '#ff4544',
-                ],
-                [
-                    'url' => '/pages/cart/cart',
-                    'base_url' => '/pages/cart/cart',
-                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-cart.png',
-                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-cart.active.png',
-                    'text' => '购物车',
-                    'color' => '#888',
-                    'active_color' => '#ff4544',
-                ],
-                [
-                    'url' => '/pages/user/user',
-                    'base_url' => '/pages/user/user',
-                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-user.png',
-                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-user.active.png',
-                    'text' => '我',
-                    'color' => '#888',
-                    'active_color' => '#ff4544',
-                ],
-            ],
-        ];
-        $navbar = Option::get('navbar', get_store_id(), 'navbar', Json::encode($default_navbar));
-        return Json::decode($navbar['value']);
-    }
-
-    /**
-     * @return array
-     */
-    public static function getMchNavbar($store_id, $mch_id)
-    {
-        $default_navbar = [
-            'background_image' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX///+nxBvIAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==',
-            'border_color' => '#ffffff',
-            'navs' => [
-                [
-                    'url' => '/mch/shop/shop?tab=1&mch_id='.$mch_id,
-                    'new_url' => '/mch/shop/shop?tab=1&mch_id='.$mch_id,
-                    'base_url' => '/mch/shop/shop?tab=1',
-                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-shouye.png',
-                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-shouye-active.png',
-                    'text' => '店铺首页',
-                    'color' => '#888',
-                    'active_color' => '#ff4544',
-                    'open_type' => "mch",
-                ],
-                [
-                    'url' => '/mch/shop/shop?tab=2&mch_id='.$mch_id,
-                    'new_url' => '/mch/shop/shop?tab=2&mch_id='.$mch_id,
-                    'base_url' => '/mch/shop/shop?tab=2',
-                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-quanbu.png',
-                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-quanbu-active.png',
-                    'text' => '全部商品',
-                    'color' => '#888',
-                    'active_color' => '#ff4544',
-                    'open_type' => "mch",
-                ],
-                [
-                    'url' => '/mch/shop/shop?tab=3&mch_id='.$mch_id,
-                    'new_url' => '/mch/shop/shop?tab=3&mch_id='.$mch_id,
-                    'base_url' => '/mch/shop/shop?tab=3',
-                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-xinpin.png',
-                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-xinpi-active.png',
-                    'text' => '新品上架',
-                    'color' => '#888',
-                    'active_color' => '#ff4544',
-                    'open_type' => "mch",
-                ],
-                [
-                    'url' => '/mch/shop-cat/shop-cat?mch_id='.$mch_id,
-                    'new_url' => '/mch/shop-cat/shop-cat?mch_id='.$mch_id,
-                    'base_url' => '/mch/shop-cat/shop-cat',
-                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-list.png',
-                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-list-active.png',
-                    'text' => '商品分类',
-                    'color' => '#888',
-                    'active_color' => '#ff4544',
-                    'open_type' => "mch",
-                ],
-                [
-                    'url' => '/pages/scan-code-pay/scan-code-pay?mch_id='.$mch_id,
-                    'new_url' => '/pages/scan-code-pay/scan-code-pay?mch_id='.$mch_id,
-                    'base_url' => '/pages/scan-code-pay/scan-code-pay',
-                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-pri.png',
-                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-pri-active.png',
-                    'text' => '买单',
-                    'color' => '#888',
-                    'active_color' => '#ff4544',
-                    'open_type' => "mch",
-                ],
-            ],
-        ];
-        $navbar = Option::get('mch_navbar_'.$mch_id, $store_id, 'navbar', Json::encode($default_navbar));
-        return Json::decode($navbar['value']);
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\helpers\Json;
+
+class AppNavbar
+{
+    /**
+     * @return array
+     */
+    public static function getNavbar($store_id)
+    {
+        $default_navbar = [
+            'background_image' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX///+nxBvIAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==',
+            'border_color' => '#ffffff',
+            'navs' => [
+                [
+                    'url' => '/pages/index/index',
+                    'base_url' => '/pages/index/index',
+                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-index.png',
+                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-index.active.png',
+                    'text' => '商城',
+                    'color' => '#888',
+                    'active_color' => '#ff4544',
+                ],
+                [
+                    'url' => '/pages/cat/cat',
+                    'base_url' => '/pages/cat/cat',
+                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-cat.png',
+                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-cat.active.png',
+                    'text' => '分类',
+                    'color' => '#888',
+                    'active_color' => '#ff4544',
+                ],
+                [
+                    'url' => '/pages/cart/cart',
+                    'base_url' => '/pages/cart/cart',
+                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-cart.png',
+                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-cart.active.png',
+                    'text' => '购物车',
+                    'color' => '#888',
+                    'active_color' => '#ff4544',
+                ],
+                [
+                    'url' => '/pages/user/user',
+                    'base_url' => '/pages/user/user',
+                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-user.png',
+                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/appnavbar/nav-icon-user.active.png',
+                    'text' => '我',
+                    'color' => '#888',
+                    'active_color' => '#ff4544',
+                ],
+            ],
+        ];
+        $navbar = Option::get('navbar', get_store_id(), 'navbar', Json::encode($default_navbar));
+        return Json::decode($navbar['value']);
+    }
+
+    /**
+     * @return array
+     */
+    public static function getMchNavbar($store_id, $mch_id)
+    {
+        $default_navbar = [
+            'background_image' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX///+nxBvIAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==',
+            'border_color' => '#ffffff',
+            'navs' => [
+                [
+                    'url' => '/mch/shop/shop?tab=1&mch_id='.$mch_id,
+                    'new_url' => '/mch/shop/shop?tab=1&mch_id='.$mch_id,
+                    'base_url' => '/mch/shop/shop?tab=1',
+                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-shouye.png',
+                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-shouye-active.png',
+                    'text' => '店铺首页',
+                    'color' => '#888',
+                    'active_color' => '#ff4544',
+                    'open_type' => "mch",
+                ],
+                [
+                    'url' => '/mch/shop/shop?tab=2&mch_id='.$mch_id,
+                    'new_url' => '/mch/shop/shop?tab=2&mch_id='.$mch_id,
+                    'base_url' => '/mch/shop/shop?tab=2',
+                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-quanbu.png',
+                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-quanbu-active.png',
+                    'text' => '全部商品',
+                    'color' => '#888',
+                    'active_color' => '#ff4544',
+                    'open_type' => "mch",
+                ],
+                [
+                    'url' => '/mch/shop/shop?tab=3&mch_id='.$mch_id,
+                    'new_url' => '/mch/shop/shop?tab=3&mch_id='.$mch_id,
+                    'base_url' => '/mch/shop/shop?tab=3',
+                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-xinpin.png',
+                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-xinpi-active.png',
+                    'text' => '新品上架',
+                    'color' => '#888',
+                    'active_color' => '#ff4544',
+                    'open_type' => "mch",
+                ],
+                [
+                    'url' => '/mch/shop-cat/shop-cat?mch_id='.$mch_id,
+                    'new_url' => '/mch/shop-cat/shop-cat?mch_id='.$mch_id,
+                    'base_url' => '/mch/shop-cat/shop-cat',
+                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-list.png',
+                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-list-active.png',
+                    'text' => '商品分类',
+                    'color' => '#888',
+                    'active_color' => '#ff4544',
+                    'open_type' => "mch",
+                ],
+                [
+                    'url' => '/pages/scan-code-pay/scan-code-pay?mch_id='.$mch_id,
+                    'new_url' => '/pages/scan-code-pay/scan-code-pay?mch_id='.$mch_id,
+                    'base_url' => '/pages/scan-code-pay/scan-code-pay',
+                    'icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-pri.png',
+                    'active_icon' => \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . '/web/v1/statics/images/mchnavbar/icon-pri-active.png',
+                    'text' => '买单',
+                    'color' => '#888',
+                    'active_color' => '#ff4544',
+                    'open_type' => "mch",
+                ],
+            ],
+        ];
+        $navbar = Option::get('mch_navbar_'.$mch_id, $store_id, 'navbar', Json::encode($default_navbar));
+        return Json::decode($navbar['value']);
+    }
+}

+ 65 - 65
models/Article.php

@@ -1,65 +1,65 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use app\models\common\admin\log\CommonActionLog;
-use Yii;
-
-/**
- * This is the model class for table "{{%article}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $article_cat_id
- * @property string $title
- * @property string $content
- * @property integer $sort
- * @property integer $addtime
- * @property integer $is_delete
- * @property integer $is_show
- */
-class Article extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%article}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'article_cat_id', 'sort', 'addtime', 'is_delete', 'is_show'], 'integer'],
-            [['content'], 'string'],
-            [['title'], 'string', 'max' => 255],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => 'Store ID',
-            'article_cat_id' => '分类id:1=关于我们,2=服务中心',
-            'title' => '标题',
-            'content' => '内容',
-            'sort' => '排序:升序',
-            'addtime' => 'Addtime',
-            'is_delete' => 'Is Delete',
-            'is_show' => '是否显示',
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use app\models\common\admin\log\CommonActionLog;
+use Yii;
+
+/**
+ * This is the model class for table "{{%article}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $article_cat_id
+ * @property string $title
+ * @property string $content
+ * @property integer $sort
+ * @property integer $addtime
+ * @property integer $is_delete
+ * @property integer $is_show
+ */
+class Article extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%article}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'article_cat_id', 'sort', 'addtime', 'is_delete', 'is_show'], 'integer'],
+            [['content'], 'string'],
+            [['title'], 'string', 'max' => 255],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID',
+            'article_cat_id' => '分类id:1=关于我们,2=服务中心',
+            'title' => '标题',
+            'content' => '内容',
+            'sort' => '排序:升序',
+            'addtime' => 'Addtime',
+            'is_delete' => 'Is Delete',
+            'is_show' => '是否显示',
+        ];
+    }
+
+}

+ 55 - 55
models/Attr.php

@@ -1,55 +1,55 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%attr}}".
- *
- * @property integer $id
- * @property integer $attr_group_id
- * @property string $attr_name
- * @property integer $is_delete
- * @property integer $is_default
- */
-class Attr extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%attr}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['attr_group_id', 'attr_name'], 'required'],
-            [['attr_group_id', 'is_delete', 'is_default'], 'integer'],
-            [['attr_name'], 'string', 'max' => 255],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'attr_group_id' => 'Attr Group ID',
-            'attr_name' => 'Attr Name',
-            'is_delete' => 'Is Delete',
-            'is_default' => '是否是默认属性',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%attr}}".
+ *
+ * @property integer $id
+ * @property integer $attr_group_id
+ * @property string $attr_name
+ * @property integer $is_delete
+ * @property integer $is_default
+ */
+class Attr extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%attr}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['attr_group_id', 'attr_name'], 'required'],
+            [['attr_group_id', 'is_delete', 'is_default'], 'integer'],
+            [['attr_name'], 'string', 'max' => 255],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'attr_group_id' => 'Attr Group ID',
+            'attr_name' => 'Attr Name',
+            'is_delete' => 'Is Delete',
+            'is_default' => '是否是默认属性',
+        ];
+    }
+}

+ 64 - 64
models/AttrGroup.php

@@ -1,64 +1,64 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%attr_group}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property string $attr_group_name
- * @property integer $is_delete
- */
-class AttrGroup extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%attr_group}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'attr_group_name'], 'required'],
-            [['store_id', 'is_delete'], 'integer'],
-            [['attr_group_name'], 'string', 'max' => 255],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => 'Store ID',
-            'attr_group_name' => 'Attr Group Name',
-            'is_delete' => 'Is Delete',
-        ];
-    }
-
-    private $attrList;
-
-    public function getAttrList()
-    {
-        if ($this->attrList) {
-            return $this->attrList;
-        }
-        $this->attrList = Attr::findAll(['is_delete' => 0, 'attr_group_id' => $this->id]);
-        return $this->attrList;
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%attr_group}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property string $attr_group_name
+ * @property integer $is_delete
+ */
+class AttrGroup extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%attr_group}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'attr_group_name'], 'required'],
+            [['store_id', 'is_delete'], 'integer'],
+            [['attr_group_name'], 'string', 'max' => 255],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID',
+            'attr_group_name' => 'Attr Group Name',
+            'is_delete' => 'Is Delete',
+        ];
+    }
+
+    private $attrList;
+
+    public function getAttrList()
+    {
+        if ($this->attrList) {
+            return $this->attrList;
+        }
+        $this->attrList = Attr::findAll(['is_delete' => 0, 'attr_group_id' => $this->id]);
+        return $this->attrList;
+    }
+}

+ 107 - 114
models/AttrLibrary.php

@@ -1,114 +1,107 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * Class AttrLibrary
- * @package app\modules\common\models
- * @property integer $id
- * @property integer $store_id
- * @property integer $supplier_id
- * @property integer $parent_id
- * @property string $name
- * @property integer $sort
- * @property integer $is_delete
- * @property string $type
- * @property string $created_at
- * @property string $updated_at
- */
-class AttrLibrary extends ActiveRecord
-{
-    /**
-     * 类型
-     */
-    const TYPE_0 = 0;
-
-    /**
-     * 规格
-     */
-    const TYPE_1 = 1;
-
-    /**
-     * 属性
-     */
-    const TYPE_2 = 2;
-
-
-    public function behaviors()
-    {
-        return [
-            [
-                // 自动更新创建和更新时间
-                'class' => TimestampBehavior::class,
-                'value' => time()
-            ]
-        ];
-    }
-
-    public static function tableName()
-    {
-        return '{{%attr_library}}';
-    }
-
-    public function rules()
-    {
-        return [
-            [['store_id', 'name',], 'required'],
-            [['store_id', 'parent_id', 'sort', 'created_at', 'updated_at', 'is_delete', 'type', 'supplier_id'], 'integer'],
-            [['name'], 'string', 'max' => 255],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => '商城id',
-            'supplier_id' => '供货商ID',
-            'parent_id' => '上级分类id',
-            'name' => '分类名称',
-            'sort' => '排序,升序',
-            'created_at' => '创建时间',
-            'updated_at' => '更新时间',
-            'is_delete' => 'Is Delete',
-            'type' => '类型',
-        ];
-    }
-
-    /**
-     * 获取所有的分类
-     * @param int $store_id
-     * @param int $parent_id
-     * @return array
-     */
-    public static function getList($store_id = 1, $parent_id = 0, $supplier_id = 0)
-    {
-        $res = [];
-        $where = [
-            'parent_id' => $parent_id,
-            'is_delete' => 0,
-            'store_id' => $store_id
-        ];
-        if ($supplier_id) {
-            $where['store_id'] = 0;
-            $where['supplier_id'] = $supplier_id;
-        }
-        $query = self::find()->where($where)->orderBy(['sort'=>SORT_DESC]);
-        $list = $query->asArray()->all();
-        if (empty($list)) {
-            return $res;
-        }
-        foreach ($list as &$val) {
-            $val['children'] = self::getList($store_id, $val['id'], $supplier_id);
-            $res[] = $val;
-        }
-        return $res;
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * Class AttrLibrary
+ * @package app\modules\common\models
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $parent_id
+ * @property string $name
+ * @property integer $sort
+ * @property integer $is_delete
+ * @property string $type
+ * @property string $created_at
+ * @property string $updated_at
+ */
+class AttrLibrary extends ActiveRecord
+{
+    /**
+     * 类型
+     */
+    const TYPE_0 = 0;
+
+    /**
+     * 规格
+     */
+    const TYPE_1 = 1;
+
+    /**
+     * 属性
+     */
+    const TYPE_2 = 2;
+
+
+    public function behaviors()
+    {
+        return [
+            [
+                // 自动更新创建和更新时间
+                'class' => TimestampBehavior::class,
+                'value' => time()
+            ]
+        ];
+    }
+
+    public static function tableName()
+    {
+        return '{{%attr_library}}';
+    }
+
+    public function rules()
+    {
+        return [
+            [['store_id', 'name',], 'required'],
+            [['store_id', 'parent_id', 'sort', 'created_at', 'updated_at', 'is_delete', 'type'], 'integer'],
+            [['name'], 'string', 'max' => 255],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => '商城id',
+            'parent_id' => '上级分类id',
+            'name' => '分类名称',
+            'sort' => '排序,升序',
+            'created_at' => '创建时间',
+            'updated_at' => '更新时间',
+            'is_delete' => 'Is Delete',
+            'type' => '类型',
+        ];
+    }
+
+    /**
+     * 获取所有的分类
+     * @param int $store_id
+     * @param int $parent_id
+     * @return array
+     */
+    public static function getList($store_id = 1, $parent_id = 0)
+    {
+        $res = [];
+        $query = self::find()->where([
+            'parent_id' => $parent_id,
+            'is_delete' => 0,
+            'store_id' => $store_id
+        ])->orderBy(['sort'=>SORT_DESC]);
+        $list = $query->asArray()->all();
+        if (empty($list)) {
+            return $res;
+        }
+        foreach ($list as &$val) {
+            $val['children'] = self::getList($store_id, $val['id']);
+            $res[] = $val;
+        }
+        return $res;
+    }
+}

+ 85 - 85
models/AuthRole.php

@@ -1,85 +1,85 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-/**
- * Class AuthRole
- * @package app\modules\common\models
- * @property string $id
- * @property string $name
- * @property string $data
- * @property string $edit_data
- * @property string $describe
- * @property integer $status
- * @property string $created_at
- * @property string $updated_at
- * @property integer $store_id
- */
-class AuthRole extends ActiveRecord
-{
-
-    const STATUS_NORMAL = 1; // 正常
-    const STATUS_DISABLE = 0; // 禁用
-
-    public static function tableName()
-    {
-        return '{{%auth_role}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                // 自动更新创建和更新时间
-                'class' => TimestampBehavior::class,
-                'value' => date("Y-m-d H:i:s")
-            ]
-        ];
-    }
-
-    public function rules()
-    {
-        return [
-            [['id', 'status', 'store_id'], 'integer'],
-            [['name'], 'string', 'max' => 64],
-            [['name', 'data'], 'required'],
-            [['data', 'edit_data'], 'string'],
-            [['describe'], 'string', 'max' => 255],
-            [['create_at', 'update_at'], 'safe']
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'name' => '角色名称',
-            'create_at' => '创建时间',
-            'update_at' => '更新时间',
-            'data' => '角色数据',
-            'edit_data' => '角色数据',
-            'describe' => '简介',
-            'status' => '状态',
-            'store_id' => '商城id',
-        ];
-    }
-
-    /**
-     * 获取管理员
-     * @return \yii\db\ActiveQuery
-     * @throws \yii\base\InvalidConfigException
-     */
-    public function getAdmins()
-    {
-        return $this->hasMany(Admin::class, ['id' => 'admin_id'])
-            ->where(['type' => 'staff', 'is_delete' => 0])
-            ->viaTable('{{%admin_role}}', ['role_id' => 'id']);
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+/**
+ * Class AuthRole
+ * @package app\modules\common\models
+ * @property string $id
+ * @property string $name
+ * @property string $data
+ * @property string $edit_data
+ * @property string $describe
+ * @property integer $status
+ * @property string $created_at
+ * @property string $updated_at
+ * @property integer $store_id
+ */
+class AuthRole extends ActiveRecord
+{
+
+    const STATUS_NORMAL = 1; // 正常
+    const STATUS_DISABLE = 0; // 禁用
+
+    public static function tableName()
+    {
+        return '{{%auth_role}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                // 自动更新创建和更新时间
+                'class' => TimestampBehavior::class,
+                'value' => date("Y-m-d H:i:s")
+            ]
+        ];
+    }
+
+    public function rules()
+    {
+        return [
+            [['id', 'status', 'store_id'], 'integer'],
+            [['name'], 'string', 'max' => 64],
+            [['name', 'data'], 'required'],
+            [['data', 'edit_data'], 'string'],
+            [['describe'], 'string', 'max' => 255],
+            [['create_at', 'update_at'], 'safe']
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'name' => '角色名称',
+            'create_at' => '创建时间',
+            'update_at' => '更新时间',
+            'data' => '角色数据',
+            'edit_data' => '角色数据',
+            'describe' => '简介',
+            'status' => '状态',
+            'store_id' => '商城id',
+        ];
+    }
+
+    /**
+     * 获取管理员
+     * @return \yii\db\ActiveQuery
+     * @throws \yii\base\InvalidConfigException
+     */
+    public function getAdmins()
+    {
+        return $this->hasMany(Admin::class, ['id' => 'admin_id'])
+            ->where(['type' => 'staff', 'is_delete' => 0])
+            ->viaTable('{{%admin_role}}', ['role_id' => 'id']);
+    }
+}

+ 107 - 107
models/Banner.php

@@ -1,107 +1,107 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%banner}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property string $pic_url
- * @property string $title
- * @property string $page_url
- * @property integer $sort
- * @property integer $created_at
- * @property integer $is_delete
- * @property integer $type
- * @property string $open_type
- * @property integer $md_id
- */
-class Banner extends \yii\db\ActiveRecord
-{
-
-    /**
-     * 商城
-     */
-    const TYPE_STORE = 1;
-
-    /**
-     * 点餐
-     */
-    const TYPE_FOOD = 2;
-
-
-    /**
-     * SAAS
-     */
-    const TYPE_SAAS = 3;
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%banner}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'pic_url', 'title'], 'required'],
-            [['store_id', 'sort', 'created_at', 'is_delete', 'type', 'md_id'], 'integer'],
-            [['pic_url', 'page_url'], 'string'],
-            [['title', 'open_type'], 'string', 'max' => 255],
-            ['type', 'default', 'value' => 1,],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => '商城id',
-            'pic_url' => '图片url',
-            'title' => '标题',
-            'page_url' => '页面路径',
-            'sort' => '排序,升序',
-            'created_at' => '添加时间',
-            'is_delete' => '是否删除:0=未删除,1=已删除',
-            'type' => '类型1 => 商城,2 => 点餐',
-            'open_type' => 'Open Type',
-        ];
-    }
-
-    /**
-     * @return array
-     */
-    public function saveBanner()
-    {
-        if ($this->validate()) {
-            if ($this->save()) {
-                return [
-                    'code' => 0,
-                    'msg' => '成功'
-                ];
-            } else {
-                return [
-                    'code' => 1,
-                    'msg' => '失败'
-                ];
-            }
-        } else {
-            return $this->errors[0];
-        }
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%banner}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property string $pic_url
+ * @property string $title
+ * @property string $page_url
+ * @property integer $sort
+ * @property integer $created_at
+ * @property integer $is_delete
+ * @property integer $type
+ * @property string $open_type
+ * @property integer $md_id
+ */
+class Banner extends \yii\db\ActiveRecord
+{
+
+    /**
+     * 商城
+     */
+    const TYPE_STORE = 1;
+
+    /**
+     * 点餐
+     */
+    const TYPE_FOOD = 2;
+
+
+    /**
+     * SAAS
+     */
+    const TYPE_SAAS = 3;
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%banner}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'pic_url', 'title'], 'required'],
+            [['store_id', 'sort', 'created_at', 'is_delete', 'type', 'md_id'], 'integer'],
+            [['pic_url', 'page_url'], 'string'],
+            [['title', 'open_type'], 'string', 'max' => 255],
+            ['type', 'default', 'value' => 1,],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => '商城id',
+            'pic_url' => '图片url',
+            'title' => '标题',
+            'page_url' => '页面路径',
+            'sort' => '排序,升序',
+            'created_at' => '添加时间',
+            'is_delete' => '是否删除:0=未删除,1=已删除',
+            'type' => '类型1 => 商城,2 => 点餐',
+            'open_type' => 'Open Type',
+        ];
+    }
+
+    /**
+     * @return array
+     */
+    public function saveBanner()
+    {
+        if ($this->validate()) {
+            if ($this->save()) {
+                return [
+                    'code' => 0,
+                    'msg' => '成功'
+                ];
+            } else {
+                return [
+                    'code' => 1,
+                    'msg' => '失败'
+                ];
+            }
+        } else {
+            return $this->errors[0];
+        }
+    }
+}

+ 55 - 55
models/BonusPool.php

@@ -1,55 +1,55 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%bonus_pool}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $start_time
- * @property integer $end_time
- * @property integer $created_at
- */
-class BonusPool extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%bonus_pool}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'start_time', 'end_time', 'created_at'], 'integer'],
-            [['created_at'], 'safe']
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%bonus_pool}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $start_time
+ * @property integer $end_time
+ * @property integer $created_at
+ */
+class BonusPool extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%bonus_pool}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'start_time', 'end_time', 'created_at'], 'integer'],
+            [['created_at'], 'safe']
+        ];
+    }
+}

+ 59 - 59
models/BonusPoolDetail.php

@@ -1,59 +1,59 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%bonus_pool_detail}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $order_id
- * @property integer $money
- * @property integer $pool_level_id
- * @property string  $desc
- * @property integer $created_at
- */
-class BonusPoolDetail extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%bonus_pool_detail}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'order_id', 'pool_level_id'], 'integer'],
-            [['desc'], 'string'],
-            [['money'], 'number'],
-            [['created_at'], 'safe']
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%bonus_pool_detail}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $order_id
+ * @property integer $money
+ * @property integer $pool_level_id
+ * @property string  $desc
+ * @property integer $created_at
+ */
+class BonusPoolDetail extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%bonus_pool_detail}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'order_id', 'pool_level_id'], 'integer'],
+            [['desc'], 'string'],
+            [['money'], 'number'],
+            [['created_at'], 'safe']
+        ];
+    }
+}

+ 61 - 72
models/BonusPoolLevel.php

@@ -1,72 +1,61 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%bonus_pool_level}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $pool_id
- * @property integer $money
- * @property integer $level_id
- * @property string $user_id
- * @property integer $is_send
- * @property integer $share_type
- * @property integer $send_time
- * @property integer $created_at
- */
-class BonusPoolLevel extends \yii\db\ActiveRecord
-{
-    /**
-     * 平均分红
-     */
-    const SHARE_TYPE_AVERAGE = 0;
-
-    /**
-     * 加权分红
-     */
-    const SHARE_TYPE_WEIGHT = 1;
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%bonus_pool_level}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'pool_id', 'level_id', 'is_send', 'send_time'], 'integer'],
-            [['money'], 'number'],
-            [['user_id'], 'string'],
-            [['created_at'], 'safe']
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%bonus_pool_level}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $pool_id
+ * @property integer $money
+ * @property integer $level_id
+ * @property string $user_id
+ * @property integer $is_send
+ * @property integer $send_time
+ * @property integer $created_at
+ */
+class BonusPoolLevel extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%bonus_pool_level}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'pool_id', 'level_id', 'is_send', 'send_time'], 'integer'],
+            [['money'], 'number'],
+            [['user_id'], 'string'],
+            [['created_at'], 'safe']
+        ];
+    }
+}

+ 45 - 45
models/BookingGoodsCat.php

@@ -1,45 +1,45 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%booking_goods_cat}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property string  $name
- * @property string  $pic_url
- * @property integer $sort
- * @property integer $is_delete
- * @property integer $is_show
- * @property integer $created_at
- * @property integer $updated_at
- */
-class BookingGoodsCat extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%booking_goods_cat}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%booking_goods_cat}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property string  $name
+ * @property string  $pic_url
+ * @property integer $sort
+ * @property integer $is_delete
+ * @property integer $is_show
+ * @property integer $created_at
+ * @property integer $updated_at
+ */
+class BookingGoodsCat extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%booking_goods_cat}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+}

+ 56 - 56
models/BookingGoodsExt.php

@@ -1,56 +1,56 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use app\jobs\storeSync\DiyCommon;
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%booking_goods_ext}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $goods_id
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $cat_id
-
- */
-class BookingGoodsExt extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%booking_goods_ext}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-            ]
-        ];
-    }
-
-    public function beforeSave($insert)
-    {
-
-        return parent::beforeSave($insert);
-    }
-
-    public function afterSave($insert, $changedAttributes)
-    {
-        parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
-        (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_BOOKING_GOODS);
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use app\jobs\storeSync\DiyCommon;
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%booking_goods_ext}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $goods_id
+ * @property integer $created_at
+ * @property integer $updated_at
+ * @property integer $cat_id
+
+ */
+class BookingGoodsExt extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%booking_goods_ext}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+            ]
+        ];
+    }
+
+    public function beforeSave($insert)
+    {
+
+        return parent::beforeSave($insert);
+    }
+
+    public function afterSave($insert, $changedAttributes)
+    {
+        parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
+        (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_BOOKING_GOODS);
+    }
+
+}

+ 112 - 112
models/BookingOrderExt.php

@@ -1,112 +1,112 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use app\utils\Notice\NoticeSend;
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%booking_order_ext}}".
- *
- * @property integer $id
- */
-class BookingOrderExt extends \yii\db\ActiveRecord
-{
-    
-    const IGNORE_ORDER_IDS = 'IGNORE_ORDER_IDS';
-    
-    const STATUS_EXT_WAIT_PAY = 5;      //待支付
-    const STATUS_EXT_WAIT_SYS_CONFIRM = 10;    //待系统确认
-    const STATUS_EXT_HAS_SYS_CONFIRM = 20;    //系统确认/待开始
-    const STATUS_EXT_START = 50;        //进行中
-    const STATUS_EXT_CANCEL = 70;       //取消
-    const STATUS_EXT_FINISH = 100;      //完成
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%booking_order_ext}}';
-    }
-
-    public function behaviors()
-    {
-        return [];
-    }
-    public static function afterOrderSave($insert, $changedAttributes, $order) {
-        try{
-            if($order->order_type != 2){
-                return;
-            }
-            self::statusAfterOrderSave($insert, $changedAttributes, $order);
-        } catch (\Exception $ex) {
-            debug_log([__METHOD__, $insert, $changedAttributes, $ex->getMessage()], __CLASS__ . '.log');
-        }
-    }
-    public static function statusAfterOrderSave($insert, $changedAttributes, $order) {
-        debug_log([__METHOD__, $insert, isset($changedAttributes['is_pay']), $order->is_pay, $changedAttributes, $order], __CLASS__ . '.log');
-        if($insert){
-            $self = new self();
-            $self->order_id = $order->id;
-            $self->store_id = $order->store_id;
-            $save = $self->save();
-            if(!$save){
-                debug_log([__METHOD__, $self->getErrors()], __CLASS__ . '.log');
-            }
-        }
-        if(isset($changedAttributes['is_pay']) && ($order->is_pay == 1)){
-            debug_log([__METHOD__, 'is_pay', $order->is_pay, $order->pay_price, $order->id], __CLASS__ . '.log');
-//            if($order->pay_price == 0){
-//                self::updateAll(['status_ext' => self::STATUS_EXT_HAS_SYS_CONFIRM], ['order_id' => $order->id, 'status_ext' => self::STATUS_EXT_WAIT_PAY]);
-//            }else{
-                self::updateAll(['status_ext' => self::STATUS_EXT_WAIT_SYS_CONFIRM], ['order_id' => $order->id, 'status_ext' => self::STATUS_EXT_WAIT_PAY]);
-//            }
-        }
-        if(isset($changedAttributes['trade_status']) && ($order->trade_status == Order::ORDER_FLOW_CANCEL)){
-            self::updateAll(['status_ext' => self::STATUS_EXT_CANCEL], ['order_id' => $order->id]);
-        }
-        if(isset($changedAttributes['trade_status']) && ($order->trade_status == Order::ORDER_FLOW_CONFIRM)){
-            self::updateAll(['status_ext' => self::STATUS_EXT_FINISH], ['order_id' => $order->id]);
-        }
-        if(isset($changedAttributes['clerk_id']) && ($order->clerk_id > 0)){
-            $user = User::findOne($order->clerk_id);
-            $saasUser = SaasUser::findOne(['mobile' => $user['binding']]);
-            if($user && $saasUser){
-                $md_staff = MdStaff::findOne(['saas_user_id' => $saasUser['id'], 'store_id' => $order->store_id]);
-                if($md_staff){
-                    self::updateAll(['worker_id' => $md_staff['id'], 'worker_name' => $md_staff['name'], 'time_has_bind' => time()], ['order_id' => $order->id]);
-                }
-            }
-        }
-//        debug_log(['statusAfterOrderSave', $insert, $changedAttributes, $addr], __CLASS__ . '.log');
-    }
-    public static function afterOrderDetailSave($insert, $changedAttributes, $orderDetail) {
-        try{
-            $attr = json_decode($orderDetail['attr'], true);
-            self::updateAll(['booking_time_start' => $attr['start_date'], 'booking_time_end' => $attr['end_date']], ['order_id' => $orderDetail->order_id]);
-        } catch (\Exception $ex) {
-            debug_log([__METHOD__, $insert, $changedAttributes, $ex->getMessage()], __CLASS__ . '.log');
-        }
-    }
-    public function setWorker($worker_id, $worker_name) {
-        $this->worker_id = $worker_id;
-        $this->worker_name = $worker_name;
-        $this->time_has_bind = time();
-        NoticeSend::bookExamine($this->order_id, 1);
-        return $this;
-    }
-
-    public static function getWorkerOrderGroupStatus($worker_id) {
-        $order_count = self::find()->where(['worker_id' => $worker_id])
-                ->andWhere(['!=', 'status_ext', self::STATUS_EXT_CANCEL])
-                ->select('count(1) cc, status_ext')
-                ->groupBy('status_ext')->asArray()->all();
-        return $order_count;
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use app\utils\Notice\NoticeSend;
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%booking_order_ext}}".
+ *
+ * @property integer $id
+ */
+class BookingOrderExt extends \yii\db\ActiveRecord
+{
+    
+    const IGNORE_ORDER_IDS = 'IGNORE_ORDER_IDS';
+    
+    const STATUS_EXT_WAIT_PAY = 5;      //待支付
+    const STATUS_EXT_WAIT_SYS_CONFIRM = 10;    //待系统确认
+    const STATUS_EXT_HAS_SYS_CONFIRM = 20;    //系统确认/待开始
+    const STATUS_EXT_START = 50;        //进行中
+    const STATUS_EXT_CANCEL = 70;       //取消
+    const STATUS_EXT_FINISH = 100;      //完成
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%booking_order_ext}}';
+    }
+
+    public function behaviors()
+    {
+        return [];
+    }
+    public static function afterOrderSave($insert, $changedAttributes, $order) {
+        try{
+            if($order->order_type != 2){
+                return;
+            }
+            self::statusAfterOrderSave($insert, $changedAttributes, $order);
+        } catch (\Exception $ex) {
+            //debug_log([__METHOD__, $insert, $changedAttributes, $ex->getMessage()], __CLASS__ . '.log');
+        }
+    }
+    public static function statusAfterOrderSave($insert, $changedAttributes, $order) {
+        //debug_log([__METHOD__, $insert, isset($changedAttributes['is_pay']), $order->is_pay, $changedAttributes, $order], __CLASS__ . '.log');
+        if($insert){
+            $self = new self();
+            $self->order_id = $order->id;
+            $self->store_id = $order->store_id;
+            $save = $self->save();
+            if(!$save){
+                //debug_log([__METHOD__, $self->getErrors()], __CLASS__ . '.log');
+            }
+        }
+        if(isset($changedAttributes['is_pay']) && ($order->is_pay == 1)){
+            //debug_log([__METHOD__, 'is_pay', $order->is_pay, $order->pay_price, $order->id], __CLASS__ . '.log');
+//            if($order->pay_price == 0){
+//                self::updateAll(['status_ext' => self::STATUS_EXT_HAS_SYS_CONFIRM], ['order_id' => $order->id, 'status_ext' => self::STATUS_EXT_WAIT_PAY]);
+//            }else{
+                self::updateAll(['status_ext' => self::STATUS_EXT_WAIT_SYS_CONFIRM], ['order_id' => $order->id, 'status_ext' => self::STATUS_EXT_WAIT_PAY]);
+//            }
+        }
+        if(isset($changedAttributes['trade_status']) && ($order->trade_status == Order::ORDER_FLOW_CANCEL)){
+            self::updateAll(['status_ext' => self::STATUS_EXT_CANCEL], ['order_id' => $order->id]);
+        }
+        if(isset($changedAttributes['trade_status']) && ($order->trade_status == Order::ORDER_FLOW_CONFIRM)){
+            self::updateAll(['status_ext' => self::STATUS_EXT_FINISH], ['order_id' => $order->id]);
+        }
+        if(isset($changedAttributes['clerk_id']) && ($order->clerk_id > 0)){
+            $user = User::findOne($order->clerk_id);
+            $saasUser = SaasUser::findOne(['mobile' => $user['binding']]);
+            if($user && $saasUser){
+                $md_staff = MdStaff::findOne(['saas_user_id' => $saasUser['id'], 'store_id' => $order->store_id]);
+                if($md_staff){
+                    self::updateAll(['worker_id' => $md_staff['id'], 'worker_name' => $md_staff['name'], 'time_has_bind' => time()], ['order_id' => $order->id]);
+                }
+            }
+        }
+//        //debug_log(['statusAfterOrderSave', $insert, $changedAttributes, $addr], __CLASS__ . '.log');
+    }
+    public static function afterOrderDetailSave($insert, $changedAttributes, $orderDetail) {
+        try{
+            $attr = json_decode($orderDetail['attr'], true);
+            self::updateAll(['booking_time_start' => $attr['start_date'], 'booking_time_end' => $attr['end_date']], ['order_id' => $orderDetail->order_id]);
+        } catch (\Exception $ex) {
+            //debug_log([__METHOD__, $insert, $changedAttributes, $ex->getMessage()], __CLASS__ . '.log');
+        }
+    }
+    public function setWorker($worker_id, $worker_name) {
+        $this->worker_id = $worker_id;
+        $this->worker_name = $worker_name;
+        $this->time_has_bind = time();
+        NoticeSend::bookExamine($this->order_id, 1);
+        return $this;
+    }
+
+    public static function getWorkerOrderGroupStatus($worker_id) {
+        $order_count = self::find()->where(['worker_id' => $worker_id])
+                ->andWhere(['!=', 'status_ext', self::STATUS_EXT_CANCEL])
+                ->select('count(1) cc, status_ext')
+                ->groupBy('status_ext')->asArray()->all();
+        return $order_count;
+    }
+}

+ 64 - 64
models/BrowseLog.php

@@ -1,64 +1,64 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use app\models\common\admin\log\CommonActionLog;
-use Yii;
-
-/**
- * This is the model class for table "{{%browse_log}}".
- *
- */
-class BrowseLog extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%browse_log}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'user_id'], 'integer'],
-            ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => 'Store ID', 
-            'user_id' => '用户 ID',      
-            'type' => '0商品记录1门店记录',        
-            'log_id' => '记录id',
-        ];
-    }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use app\models\common\admin\log\CommonActionLog;
+use Yii;
+
+/**
+ * This is the model class for table "{{%browse_log}}".
+ *
+ */
+class BrowseLog extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%browse_log}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'user_id'], 'integer'],
+            ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID', 
+            'user_id' => '用户 ID',      
+            'type' => '0商品记录1门店记录',        
+            'log_id' => '记录id',
+        ];
+    }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 49 - 49
models/BusinessCart.php

@@ -1,49 +1,49 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-
-class BusinessCart extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%business_cart}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'saas_id', 'goods_id', 'attr'], 'required'],
-            [['store_id', 'saas_id', 'goods_id', 'num', 'created_at', 'is_delete'], 'integer'],
-            [['attr'], 'string'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => 'Store ID',
-            'saas_id' => '用户id',
-            'goods_id' => '商品id',
-            'num' => '商品数量',
-            'created_at' => 'created_at',
-            'is_delete' => 'Is Delete',
-            'attr' => '规格',
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+
+class BusinessCart extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%business_cart}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'saas_id', 'goods_id', 'attr'], 'required'],
+            [['store_id', 'saas_id', 'goods_id', 'num', 'created_at', 'is_delete'], 'integer'],
+            [['attr'], 'string'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID',
+            'saas_id' => '用户id',
+            'goods_id' => '商品id',
+            'num' => '商品数量',
+            'created_at' => 'created_at',
+            'is_delete' => 'Is Delete',
+            'attr' => '规格',
+        ];
+    }
+
+}

+ 62 - 63
models/BusinessMember.php

@@ -1,63 +1,62 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-
-class BusinessMember extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%business_member}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['name','image','bg_image'], 'required'],
-            [['sort', 'give', 'give_coupon', 'give_verify','give_self','commission_type', 'right_status','get_type'], 'integer'],
-            [['image', 'bg_image','coupon_info','verify_info','right_ids','right_info','right_default','sale_info'], 'string'],
-            [['commission_one','commission_two','commission_three', 'self_info'],'number'],
-            [['give_verify'], 'default', 'value' => 0]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'name'             => '会员卡名称',
-            'image'            => '图片',
-            'bg_image'         => '背景图片',
-            'get_type'         => '获取方式',
-            'sale_info'        => '购买详情',
-            'give'             => '赠送开关',
-            'give_coupon'      => '优惠券赠送开关',
-            'give_verify'      => '核销卡赠送开关',
-            'give_self'        => '自购返利',
-            'coupon_info'      => '赠送优惠券信息',
-            'verify_info'      => '赠送卡券信息',
-            'self_info'        => '返利佣金',
-            'commission_type'  => '佣金类型:1百分比 2固定金额',
-            'commission_one'   => '一级佣金',
-            'commission_two'   => '二级佣金',
-            'commission_three' => '三级佣金',
-            'right_status'     => '权益开关',
-            'right_ids'        => '权利ids',
-            'right_info'       => '权益信息',
-            'right_default'    => '权益详情',
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+
+class BusinessMember extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%business_member}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['name','image','bg_image'], 'required'],
+            [['sort', 'give', 'give_coupon', 'give_verify','give_self','commission_type', 'right_status','get_type'], 'integer'],
+            [['image', 'bg_image','coupon_info','verify_info','right_ids','right_info','right_default','sale_info'], 'string'],
+            [['commission_one','commission_two','commission_three', 'self_info'],'number']
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'name'             => '会员卡名称',
+            'image'            => '图片',
+            'bg_image'         => '背景图片',
+            'get_type'         => '获取方式',
+            'sale_info'        => '购买详情',
+            'give'             => '赠送开关',
+            'give_coupon'      => '优惠券赠送开关',
+            'give_verify'      => '核销卡赠送开关',
+            'give_self'        => '自购返利',
+            'coupon_info'      => '赠送优惠券信息',
+            'verify_info'      => '赠送卡券信息',
+            'self_info'        => '返利佣金',
+            'commission_type'  => '佣金类型:1百分比 2固定金额',
+            'commission_one'   => '一级佣金',
+            'commission_two'   => '二级佣金',
+            'commission_three' => '三级佣金',
+            'right_status'     => '权益开关',
+            'right_ids'        => '权利ids',
+            'right_info'       => '权益信息',
+            'right_default'    => '权益详情',
+        ];
+    }
+
+}

+ 100 - 105
models/BusinessMemberOrder.php

@@ -1,105 +1,100 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%business_order}}".
- *
- * @property integer $id
- * @property integer $member_id
- * @property string  $order_no
- * @property integer $saas_id
- * @property string  $pay_price
- * @property integer $pay_type
- * @property integer $is_pay
- * @property integer $pay_time
- * @property integer $is_delete
- * @property integer $created_at
- * @property integer $current_level
- * @property integer $after_level
- * @property integer $combine_money
- * @property integer $is_combine_pay
- */
-class BusinessMemberOrder extends \yii\db\ActiveRecord
-{
-
-    /**
-     * 是否删除
-     */
-    CONST IS_DELETE = 1;
-    CONST NOT_DELETE = 0;
-
-    public static $valid_delete_arr = [
-        self::IS_DELETE,
-        self::NOT_DELETE
-    ];
-
-    /**
-     * 是否支付
-     */
-    CONST IS_PAY = 1;
-    CONST NOT_PAY = 0;
-
-    public static $valid_pay_arr = [
-        self::IS_PAY,
-        self::NOT_PAY
-    ];
-
-    const MEMBER_TYPE_MONTH = 'month';
-    const MEMBER_TYPE_QUARTER = 'quarter';
-    const MEMBER_TYPE_YEAR = 'year';
-    const MEMBER_TYPE_PERPETUAL = 'perpetual';
-
-    const MEMBER_TYPE_ARR = [
-        self::MEMBER_TYPE_MONTH => '月卡',
-        self::MEMBER_TYPE_QUARTER => '季度卡',
-        self::MEMBER_TYPE_YEAR => '年卡',
-        self::MEMBER_TYPE_PERPETUAL => '终身'
-    ];
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%business_member_order}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['member_id', 'saas_id', 'pay_type', 'is_pay', 'pay_time', 'is_delete', 'created_at'], 'integer'],
-            [['pay_price'], 'number'],
-            [['order_no'], 'string', 'max' => 255],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'member_id'   => 'Member ID',
-            'member_type' => 'Member Type',
-            'order_no'    => '订单号',
-            'saas_id'     => '用户',
-            'pay_price'   => '支付金额',
-            'pay_type'    => '支付方式 1--微信支付 2--支付宝',
-            'is_pay'      => '是否支付 0--未支付 1--支付',
-            'pay_time'    => '支付时间',
-            'is_delete'   => 'Is Delete',
-            'created_at'  => '添加时间',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%business_order}}".
+ *
+ * @property integer $id
+ * @property integer $member_id
+ * @property string  $order_no
+ * @property integer $saas_id
+ * @property string  $pay_price
+ * @property integer $pay_type
+ * @property integer $is_pay
+ * @property integer $pay_time
+ * @property integer $is_delete
+ * @property integer $created_at
+ * @property integer $current_level
+ * @property integer $after_level
+ * @property integer $combine_money
+ * @property integer $is_combine_pay
+ * @property string $huifu_id
+ * @property string $trans_type
+ * @property string $hf_seq_id
+ * @property string $fee_amount
+ * @property string $out_trans_id
+ * @property string $party_order_id
+ * @property string $req_seq_id
+ */
+class BusinessMemberOrder extends \yii\db\ActiveRecord
+{
+
+    /**
+     * 是否删除
+     */
+    CONST IS_DELETE = 1;
+    CONST NOT_DELETE = 0;
+
+    public static $valid_delete_arr = [
+        self::IS_DELETE,
+        self::NOT_DELETE
+    ];
+
+    /**
+     * 是否支付
+     */
+    CONST IS_PAY = 1;
+    CONST NOT_PAY = 0;
+
+    public static $valid_pay_arr = [
+        self::IS_PAY,
+        self::NOT_PAY
+    ];
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%business_member_order}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['member_id', 'saas_id', 'pay_type', 'is_pay', 'pay_time', 'is_delete', 'created_at'], 'integer'],
+            [['pay_price'], 'number'],
+            [['order_no'], 'string', 'max' => 255],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'member_id'   => 'Member ID',
+            'member_type' => 'Member Type',
+            'order_no'    => '订单号',
+            'saas_id'     => '用户',
+            'pay_price'   => '支付金额',
+            'pay_type'    => '支付方式 1--微信支付 2--支付宝',
+            'is_pay'      => '是否支付 0--未支付 1--支付',
+            'pay_time'    => '支付时间',
+            'is_delete'   => 'Is Delete',
+            'created_at'  => '添加时间',
+        ];
+    }
+}

+ 73 - 73
models/BusinessRightDuration.php

@@ -1,73 +1,73 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%business_order}}".
- *
- * @property integer $id
- * @property integer $member_id
- * @property string  $order_no
- * @property integer $saas_id
- * @property string  $pay_price
- * @property integer $pay_type
- * @property integer $is_pay
- * @property integer $pay_time
- * @property integer $is_delete
- * @property integer $created_at
- * @property integer $current_level
- * @property integer $after_level
- * @property integer $combine_money
- * @property integer $is_combine_pay
- */
-class BusinessRightDuration extends \yii\db\ActiveRecord
-{
-
-    //后台开通
-    const FROM_ADMIN = 1;
-    //消费开通
-    const FROM_PAYSUM = 2;
-    //会员卡开通
-    const FROM_CARD = 3;
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%business_right_duration}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['saas_id','right_id','created_at','is_delete','expire_time'], 'integer'],
-            [['from'], 'safe'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'saas_id'      => '用户',
-            'right_id'     => '权限id',
-            'created_at'   => '创建时间',
-            'is_delete'    => 'Is Delete',
-            'expire_time'  => '过期时间',
-            'from'  => '开通渠道',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%business_order}}".
+ *
+ * @property integer $id
+ * @property integer $member_id
+ * @property string  $order_no
+ * @property integer $saas_id
+ * @property string  $pay_price
+ * @property integer $pay_type
+ * @property integer $is_pay
+ * @property integer $pay_time
+ * @property integer $is_delete
+ * @property integer $created_at
+ * @property integer $current_level
+ * @property integer $after_level
+ * @property integer $combine_money
+ * @property integer $is_combine_pay
+ */
+class BusinessRightDuration extends \yii\db\ActiveRecord
+{
+
+    //后台开通
+    const FROM_ADMIN = 1;
+    //消费开通
+    const FROM_PAYSUM = 2;
+    //会员卡开通
+    const FROM_CARD = 3;
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%business_right_duration}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['saas_id','right_id','created_at','is_delete','expire_time'], 'integer'],
+            [['from'], 'safe'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'saas_id'      => '用户',
+            'right_id'     => '权限id',
+            'created_at'   => '创建时间',
+            'is_delete'    => 'Is Delete',
+            'expire_time'  => '过期时间',
+            'from'  => '开通渠道',
+        ];
+    }
+}

+ 77 - 77
models/BusinessRightInfo.php

@@ -1,77 +1,77 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use app\models\common\Upload;
-use Yii;
-
-/**
- * This is the model class for table "{{%banner}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property string $pic_url
- * @property string $title
- * @property string $page_url
- * @property integer $sort
- * @property integer $created_at
- * @property integer $is_delete
- * @property integer $type
- * @property string $open_type
- * @property integer $md_id
- */
-class BusinessRightInfo extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%business_right_info}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id'          => 'ID',
-            'name'        => '权限名称',
-            'explanation' => '权限说明',
-        ];
-    }
-
-
-
-    public static function resetRightInfo($rightIds = [], $field = '') {
-        $query = self::find()->where(['is_delete' => 0])->orderBy('id ASC');
-
-        if (!empty($rightIds)) {
-            $query->andWhere(['id' => $rightIds]);
-        }
-
-        if (trim($field)) {
-            $query->select($field);
-        }
-
-        $rightInfo = $query->asArray()->all();
-        $resetData = [];
-        foreach ($rightInfo as $index => &$item) {
-            if (intval($item['id']) === 3) {
-                $resetData = $item;
-                unset($rightInfo[$index]);
-            }
-            if (intval($item['id']) === 4) {
-                $item['name'] = $resetData['name'];
-                $item['explanation'] = $resetData['explanation'];
-            }
-        }
-        return array_values($rightInfo);
-
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use app\models\common\Upload;
+use Yii;
+
+/**
+ * This is the model class for table "{{%banner}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property string $pic_url
+ * @property string $title
+ * @property string $page_url
+ * @property integer $sort
+ * @property integer $created_at
+ * @property integer $is_delete
+ * @property integer $type
+ * @property string $open_type
+ * @property integer $md_id
+ */
+class BusinessRightInfo extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%business_right_info}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id'          => 'ID',
+            'name'        => '权限名称',
+            'explanation' => '权限说明',
+        ];
+    }
+
+
+
+    public static function resetRightInfo($rightIds = [], $field = '') {
+        $query = self::find()->where(['is_delete' => 0])->orderBy('id ASC');
+
+        if (!empty($rightIds)) {
+            $query->andWhere(['id' => $rightIds]);
+        }
+
+        if (trim($field)) {
+            $query->select($field);
+        }
+
+        $rightInfo = $query->asArray()->all();
+        $resetData = [];
+        foreach ($rightInfo as $index => &$item) {
+            if (intval($item['id']) === 3) {
+                $resetData = $item;
+                unset($rightInfo[$index]);
+            }
+            if (intval($item['id']) === 4) {
+                $item['name'] = $resetData['name'];
+                $item['explanation'] = $resetData['explanation'];
+            }
+        }
+        return array_values($rightInfo);
+
+    }
+}

+ 106 - 106
models/BuyGoodsLog.php

@@ -1,107 +1,107 @@
-<?php
-/**
- * BuyGoodsLog.php
- * todo 文件描述
- * Created on 2024/4/15 13:55
- * @author: hankaige
- */
-
-namespace app\models;
-
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%card}}".
- * @property int $id
- * @property int|null $store_id
- * @property string $goods_id 卡券名称
- * @property string $nickname
- * @property string|null $avatar_url 卡券描述
- * @property int $status
- * @property int|null $updated_at
- * @property int|null $created_at
- */
-class BuyGoodsLog extends \yii\db\ActiveRecord
-{
-    const STATUS_TRUE = 1;
-    const STATUS_FALSE = 0;
-
-    public static function tableName()
-    {
-        return "{{%buy_goods_log}}";
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => [
-                        'updated_at',
-                        'created_at'
-                    ],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
-                ]
-            ]
-        ];
-    }
-
-    public function rules()
-    {
-        return [
-            [
-                [
-                    'store_id',
-                    'goods_id',
-                    'status',
-                    'updated_at',
-                    'created_at'
-                ],
-                'integer'
-            ],
-            [
-                [
-                    'nickname',
-                    'avatar_url'
-                ],
-                'string'
-            ],
-            [
-                [
-                    'store_id',
-                    'goods_id',
-                    'nickname',
-                    'avatar_url'
-                ],
-                'required'
-            ]
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => 'Store ID',
-            'goods_id' => '卡券名称',
-            'nickname' => '昵称',
-            'avatar_url' => '头像',
-            'status' => '状态',
-            'updated_at' => 'Update Time',
-            'created_at' => 'Add Time',
-        ];
-    }
-
-    public static function set($goodsId,$nickname,$avatarUrl){
-        $goods = Goods::findOne($goodsId);
-        $model = new self();
-        $model->store_id = $goods->store_id ?? 0;
-        $model->goods_id = $goodsId;
-        $model->nickname = $nickname;
-        $model->avatar_url = $avatarUrl;
-        $model->status = 0;
-        $model->save();
-    }
+<?php
+/**
+ * BuyGoodsLog.php
+ * todo 文件描述
+ * Created on 2024/4/15 13:55
+ * @author: hankaige
+ */
+
+namespace app\models;
+
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%card}}".
+ * @property int $id
+ * @property int|null $store_id
+ * @property string $goods_id 卡券名称
+ * @property string $nickname
+ * @property string|null $avatar_url 卡券描述
+ * @property int $status
+ * @property int|null $updated_at
+ * @property int|null $created_at
+ */
+class BuyGoodsLog extends \yii\db\ActiveRecord
+{
+    const STATUS_TRUE = 1;
+    const STATUS_FALSE = 0;
+
+    public static function tableName()
+    {
+        return "{{%buy_goods_log}}";
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => [
+                        'updated_at',
+                        'created_at'
+                    ],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
+                ]
+            ]
+        ];
+    }
+
+    public function rules()
+    {
+        return [
+            [
+                [
+                    'store_id',
+                    'goods_id',
+                    'status',
+                    'updated_at',
+                    'created_at'
+                ],
+                'integer'
+            ],
+            [
+                [
+                    'nickname',
+                    'avatar_url'
+                ],
+                'string'
+            ],
+            [
+                [
+                    'store_id',
+                    'goods_id',
+                    'nickname',
+                    'avatar_url'
+                ],
+                'required'
+            ]
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID',
+            'goods_id' => '卡券名称',
+            'nickname' => '昵称',
+            'avatar_url' => '头像',
+            'status' => '状态',
+            'updated_at' => 'Update Time',
+            'created_at' => 'Add Time',
+        ];
+    }
+
+    public static function set($goodsId,$nickname,$avatarUrl){
+        $goods = Goods::findOne($goodsId);
+        $model = new self();
+        $model->store_id = $goods->store_id ?? 0;
+        $model->goods_id = $goodsId;
+        $model->nickname = $nickname;
+        $model->avatar_url = $avatarUrl;
+        $model->status = 0;
+        $model->save();
+    }
 }

+ 88 - 88
models/Card.php

@@ -1,88 +1,88 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-use Yii;
-
-/**
- * This is the model class for table "{{%card}}".
- *
- * @property int $id
- * @property int|null $store_id
- * @property string $name 卡券名称
- * @property string $pic_url
- * @property string|null $content 卡券描述
- * @property int $is_delete
- * @property int|null $updated_at
- * @property int|null $created_at
- */
-class Card extends \yii\db\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%card}}';
-    }
-
-    const IS_DELETE_YES = 1;//已删除
-    const IS_DELETE_NO = 0;//未删除
-
-
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'is_delete', 'updated_at', 'created_at'], 'integer'],
-            [['name', 'pic_url', 'is_delete'], 'required'],
-            [['content'], 'string'],
-            [['name'], 'string', 'max' => 255],
-            [['pic_url'], 'string', 'max' => 2048],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => 'Store ID',
-            'name' => '卡券名称',
-            'pic_url' => 'Pic Url',
-            'content' => '卡券描述',
-            'is_delete' => 'Is Delete',
-            'updated_at' => 'Update Time',
-            'created_at' => 'Add Time',
-        ];
-    }
-
-
-
-
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+use Yii;
+
+/**
+ * This is the model class for table "{{%card}}".
+ *
+ * @property int $id
+ * @property int|null $store_id
+ * @property string $name 卡券名称
+ * @property string $pic_url
+ * @property string|null $content 卡券描述
+ * @property int $is_delete
+ * @property int|null $updated_at
+ * @property int|null $created_at
+ */
+class Card extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%card}}';
+    }
+
+    const IS_DELETE_YES = 1;//已删除
+    const IS_DELETE_NO = 0;//未删除
+
+
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'is_delete', 'updated_at', 'created_at'], 'integer'],
+            [['name', 'pic_url', 'is_delete'], 'required'],
+            [['content'], 'string'],
+            [['name'], 'string', 'max' => 255],
+            [['pic_url'], 'string', 'max' => 2048],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID',
+            'name' => '卡券名称',
+            'pic_url' => 'Pic Url',
+            'content' => '卡券描述',
+            'is_delete' => 'Is Delete',
+            'updated_at' => 'Update Time',
+            'created_at' => 'Add Time',
+        ];
+    }
+
+
+
+
+
+}

+ 47 - 47
models/CardSend.php

@@ -1,48 +1,48 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-
-use yii\base\Model;
-
-class CardSend extends Model
-{
-    public $store_id;
-    public $user_id;
-    public $order_id;
-
-    public function save()
-    {
-        $goods_list = OrderDetail::findAll(['order_id' => $this->order_id]);
-        $card_list = [];
-        foreach ($goods_list as $value) {
-            $count = 0;
-            $card = Goods::getGoodsCard($value['goods_id']);
-            while ($count < $value['num']) {
-                $card_list = array_merge($card_list, $card);
-                $count++;
-            }
-        }
-        foreach ($card_list as $index => $value) {
-            $user_card = new UserCard();
-            $user_card->store_id = $this->store_id;
-            $user_card->user_id = $this->user_id;
-            $user_card->card_id = $value['card_id'];
-            $user_card->card_name = $value['name'];
-            $user_card->card_pic_url = $value['pic_url'];
-            $user_card->card_content = $value['content'];
-            $user_card->clerk_id = 0;
-            $user_card->shop_id = 0;
-            $user_card->is_use = 0;
-            $user_card->is_delete = 0;
-            $user_card->created_at = time();
-            $user_card->order_id = $this->order_id;
-            $user_card->goods_id = $value['goods_id'];
-            $user_card->save();
-        }
-    }
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+
+use yii\base\Model;
+
+class CardSend extends Model
+{
+    public $store_id;
+    public $user_id;
+    public $order_id;
+
+    public function save()
+    {
+        $goods_list = OrderDetail::findAll(['order_id' => $this->order_id]);
+        $card_list = [];
+        foreach ($goods_list as $value) {
+            $count = 0;
+            $card = Goods::getGoodsCard($value['goods_id']);
+            while ($count < $value['num']) {
+                $card_list = array_merge($card_list, $card);
+                $count++;
+            }
+        }
+        foreach ($card_list as $index => $value) {
+            $user_card = new UserCard();
+            $user_card->store_id = $this->store_id;
+            $user_card->user_id = $this->user_id;
+            $user_card->card_id = $value['card_id'];
+            $user_card->card_name = $value['name'];
+            $user_card->card_pic_url = $value['pic_url'];
+            $user_card->card_content = $value['content'];
+            $user_card->clerk_id = 0;
+            $user_card->shop_id = 0;
+            $user_card->is_use = 0;
+            $user_card->is_delete = 0;
+            $user_card->created_at = time();
+            $user_card->order_id = $this->order_id;
+            $user_card->goods_id = $value['goods_id'];
+            $user_card->save();
+        }
+    }
 }

+ 73 - 76
models/Cart.php

@@ -1,76 +1,73 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-/*
- * @Author: your name
- * @Date: 2021-03-02 09:50:20
- * @LastEditTime: 2021-05-15 11:49:19
- * @LastEditors: Please set LastEditors
- * @Description: In User Settings Edit
- * @FilePath: \admin_php\models\Cart.php
- */
-
-namespace app\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%cart}}".
- *
- * @property int $id
- * @property int $store_id
- * @property int $user_id 用户id
- * @property int $goods_id 商品id
- * @property int $num 商品数量
- * @property int $created_at
- * @property int $is_delete
- * @property string $attr 规格
- * @property int $mch_id 入驻商id
- * @property int $md_id 门店id
- */
-class Cart extends \yii\db\ActiveRecord
-{
-    const TYPE_DEFAULT = 0;
-    const TYPE_GIVING_GIFTS = 1;    //送礼订单
-
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%cart}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'user_id', 'goods_id', 'attr'], 'required'],
-            [['store_id', 'user_id', 'goods_id', 'num', 'created_at', 'is_delete', 'mch_id', 'md_id'], 'integer'],
-            [['attr'], 'string'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => 'Store ID',
-            'user_id' => '用户id',
-            'goods_id' => '商品id',
-            'num' => '商品数量',
-            'created_at' => 'created_at',
-            'is_delete' => 'Is Delete',
-            'attr' => '规格',
-            'mch_id' => '入驻商id',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+/*
+ * @Author: your name
+ * @Date: 2021-03-02 09:50:20
+ * @LastEditTime: 2021-05-15 11:49:19
+ * @LastEditors: Please set LastEditors
+ * @Description: In User Settings Edit
+ * @FilePath: \admin_php\models\Cart.php
+ */
+
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%cart}}".
+ *
+ * @property int $id
+ * @property int $store_id
+ * @property int $user_id 用户id
+ * @property int $goods_id 商品id
+ * @property int $num 商品数量
+ * @property int $created_at
+ * @property int $is_delete
+ * @property string $attr 规格
+ * @property int $mch_id 入驻商id
+ * @property int $md_id 门店id
+ */
+class Cart extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%cart}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'user_id', 'goods_id', 'attr'], 'required'],
+            [['store_id', 'user_id', 'goods_id', 'num', 'created_at', 'is_delete', 'mch_id', 'md_id'], 'integer'],
+            [['attr'], 'string'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID',
+            'user_id' => '用户id',
+            'goods_id' => '商品id',
+            'num' => '商品数量',
+            'created_at' => 'created_at',
+            'is_delete' => 'Is Delete',
+            'attr' => '规格',
+            'mch_id' => '入驻商id',
+        ];
+    }
+}

+ 61 - 61
models/CartOffline.php

@@ -1,61 +1,61 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%cart}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $user_id
- * @property integer $goods_id
- * @property integer $num
- * @property integer $addtime
- * @property integer $is_delete
- * @property string $attr
- */
-class CartOffline extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%cart_offline}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'user_id', 'goods_id', 'attr'], 'required'],
-            [['store_id', 'user_id', 'goods_id', 'num', 'addtime', 'is_delete'], 'integer'],
-            [['attr'], 'string'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => 'Store ID',
-            'user_id' => '用户id',
-            'goods_id' => '商品id',
-            'num' => '商品数量',
-            'addtime' => 'Addtime',
-            'is_delete' => 'Is Delete',
-            'attr' => '规格',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%cart}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $user_id
+ * @property integer $goods_id
+ * @property integer $num
+ * @property integer $addtime
+ * @property integer $is_delete
+ * @property string $attr
+ */
+class CartOffline extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%cart_offline}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'user_id', 'goods_id', 'attr'], 'required'],
+            [['store_id', 'user_id', 'goods_id', 'num', 'addtime', 'is_delete'], 'integer'],
+            [['attr'], 'string'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID',
+            'user_id' => '用户id',
+            'goods_id' => '商品id',
+            'num' => '商品数量',
+            'addtime' => 'Addtime',
+            'is_delete' => 'Is Delete',
+            'attr' => '规格',
+        ];
+    }
+}

+ 290 - 676
models/Cash.php

@@ -1,676 +1,290 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-/**
- * This is the model class for table "{{%cash}}".
- *
- * @property int $id
- * @property int $user_id 用户id
- * @property int $store_id 商城id
- * @property float $price 提现金额
- * @property int $status 申请状态 0--申请中 1--确认申请 2--已打款 3--驳回  5--余额通过
- * @property int $is_delete 是否删除
- * @property int|null $created_at 添加時間
- * @property int $pay_time 付款
- * @property int $type 支付方式 0--微信支付  1--支付宝  2--银行卡  3--余额
- * @property string|null $mobile 支付宝账号
- * @property string|null $name 支付宝姓名
- * @property string|null $bank_name 开户行名称
- * @property string|null $bank_branch 银行支行
- * @property int|null $pay_type 打款方式 0--之前未统计的 1--微信自动打款 2--手动打款
- * @property string|null $order_no 微信自动打款订单号
- * @property float $service_charge 提现手续费
- * @property int|null $cash_type 0、正常,1、自提点提现
- * @property int|null $updated_at 更新时间
- * @property int $md_id 门店id
- * @property int $wx_cash_status 微信转账状态:-1未提交微信状态 0初始状态  1转账成功 2转账失败  3待确认 4转账中
- * @property string $wx_cash_error 微信转账失败错误原因
- * @property int $is_platform_transfers 微信新版打款使用平台商户号
- * @property int $wx_cash_type 微信转账类型:0=商家转账到零钱;1=新版商家转账
- * @property string $wx_cash_state 微信新版转账状态  ACCEPTED: 转账已受理;PROCESSING: 转账处理中;WAIT_USER_CONFIRM: 待收款用户确认;TRANSFERING: 转账结果尚未明确;SUCCESS: 转账成功;FAIL: 转账失败;CANCELING: 商户撤销请求受理成功;CANCELLED: 转账撤销完成
- * @property string $wx_cash_result_info 微信新版提现返回结果
- */
-
-
-
-class Cash extends \yii\db\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%cash}}';
-    }
-
-    /**
-     * 已删除
-     */
-    const IS_DELETE_YES = 1;
-
-    /**
-     * 未删除
-     */
-    const IS_DELETE_NO = 0;
-
-    /**
-     * 申请中
-     */
-    const STATUS_APPLY = 0;
-
-    /**
-     * 确认申请
-     */
-    const STATUS_CONFIRM = 1;
-
-    /**
-     * 灵工待打款
-     */
-    const STATUS_LG_CONFIRM = 6;
-
-    /**
-     * 已打款
-     */
-    const STATUS_GIVEN = 2;
-
-    /**
-     * 驳回
-     */
-    const STATUS_REFUSE = 3;
-
-    /**
-     * 手动打款
-     */
-    const STATUS_HAND = 4;
-
-    /**
-     * 余额通过
-     */
-    const STATUS_RECHARGE = 5;
-
-    /**
-     * 微信打款
-     */
-    const TYPE_WX = 0;
-
-    /**
-     * 支付宝打款
-     */
-    const TYPE_ALIPAY = 1;
-
-    /**
-     * 银行卡打款
-     */
-    const TYPE_BANK = 2;
-
-    /**
-     * 余额打款
-     */
-    const TYPE_RECHARGE = 3;
-
-    /**
-     * 灵工提现
-     */
-    const TYPE_LG = 4;
-
-
-
-    /**
-     * 之前未统计的
-     */
-    const PAY_TYPE_NO = 0;
-
-    /**
-     * 微信自动打款
-     */
-    const PAY_TYPE_WX = 1;
-
-
-    /**
-     * 灵工打款
-     */
-    const PAY_TYPE_LG = 4;
-
-
-    /**
-     * 手动拨款
-     */
-    const PAY_TYPE_HAND = 2;
-
-    /**
-     * 分销商
-     */
-    const IS_CASH_TYPE_SHARE = 0;
-    /**
-     * 自提点
-     */
-    const IS_CASH_TYPE_SHOP = 1;
-    /**
-     * 门店
-     */
-    const IS_CASH_TYPE_MD = 2;
-    /**
-     * 上门服务师傅分佣
-     */
-    const IS_CASH_TYPE_WORKER = 6;
-    /**
-     * 余额提现
-     */
-    const IS_CASH_TYPE_BALANCE = 7;
-    /**
-     * 区域代理佣金提现
-     */
-    const IS_CASH_TYPE_AREA_AGENT = 8;
-    /**
-     * 店铺内多商户提现
-     */
-    const IS_CASH_TYPE_MCH = 9;
-    /**
-     * 团队分红提现
-     */
-    const IS_CASH_TYPE_TEAM_BONUS = 10;
-    /**
-     * 团队业绩分红提现
-     */
-    const IS_CASH_TYPE_TEAM_GRADES = 11;
-
-    /**
-     * 37拼购分佣提现
-     */
-    const IS_CASH_TYPE_SHARE_GROUP_PURCHASE = 12;
-
-
-    /**
-     * 超级卖货系统提现
-     */
-    const IS_CASH_TYPE_SUPER_SALES = 13;
-
-
-    /**
-     * 增值积分系统提现
-     */
-    const IS_CASH_TYPE_INTEGRAL_APPRECIATION = 14;
-
-    /**
-     * 本地公排
-     */
-    const IS_CASH_TYPE_LOCAL_PUBLIC_RANKING = 15;
-
-
-    const WX_CASH_STATUS_INIT = 0;//初始态。 系统转账校验中
-    const WX_CASH_STATUS_SUCCESS = 1;//成功
-    const WX_CASH_STATUS_FAIL = 2;//失败
-    const WX_CASH_STATUS_WAIT_PAY = 3;//待确认 。待商户确认, 符合免密条件时, 系统会自动扭转为转账中
-    const WX_CASH_STATUS_PROCESSING = 4;//转账中。正在处理中,转账结果尚未明确
-    /**
-     * 微信转账状态
-     */
-    const WX_CASH_STATUS_ARR = [
-        'INIT'  => 0,//初始态。 系统转账校验中
-        'SUCCESS' => 1,//成功
-        'FAIL' => 2,//失败
-        'WAIT_PAY' => 3,//待确认 。待商户确认, 符合免密条件时, 系统会自动扭转为转账中
-        'PROCESSING' => 4,//转账中。正在处理中,转账结果尚未明确
-    ];
-
-    const WX_CASH_STATUS_OLD_NAME = [
-        0 => '系统转账校验中',
-        1 => '成功',
-        2 => '失败',
-        3 => '待商户确认',
-        4 => '转账中',
-    ];
-
-    const WX_CASH_FAIL_REASON = [
-        "ACCOUNT_FROZEN" => "该用户账户被冻结",
-        "REAL_NAME_CHECK_FAIL" => "收款人未实名认证,需要用户完成微信实名认证",
-        "NAME_NOT_CORRECT" => "收款人姓名校验不通过,请核实信息",
-        "OPENID_INVALID" => "Openid格式错误或者不属于商家公众账号",
-        "TRANSFER_QUOTA_EXCEED" => "超过用户单笔收款额度,核实产品设置是否准确",
-        "DAY_RECEIVED_QUOTA_EXCEED" => "超过用户单日收款额度,核实产品设置是否准确",
-        "MONTH_RECEIVED_QUOTA_EXCEED" => "超过用户单月收款额度,核实产品设置是否准确",
-        "DAY_RECEIVED_COUNT_EXCEED" => "超过用户单日收款次数,核实产品设置是否准确",
-        "PRODUCT_AUTH_CHECK_FAIL" => "未开通该权限或权限被冻结,请核实产品权限状态",
-        "OVERDUE_CLOSE" => "超过系统重试期,系统自动关闭",
-        "ID_CARD_NOT_CORRECT" => "收款人身份证校验不通过,请核实信息",
-        "ACCOUNT_NOT_EXIST" => "该用户账户不存在",
-        "TRANSFER_RISK" => "该笔转账可能存在风险,已被微信拦截",
-        "OTHER_FAIL_REASON_TYPE" => "其它失败原因",
-        "REALNAME_ACCOUNT_RECEIVED_QUOTA_EXCEED" => "用户账户收款受限,请引导用户在微信支付查看详情",
-        "RECEIVE_ACCOUNT_NOT_PERMMIT" => "未配置该用户为转账收款人,请在产品设置中调整,添加该用户为收款人",
-        "PAYEE_ACCOUNT_ABNORMAL" => "用户账户收款异常,请联系用户完善其在微信支付的身份信息以继续收款",
-        "PAYER_ACCOUNT_ABNORMAL" => "商户账户付款受限,可前往商户平台获取解除功能限制指引",
-        "TRANSFER_SCENE_UNAVAILABLE" => "该转账场景暂不可用,请确认转账场景ID是否正确",
-        "TRANSFER_SCENE_INVALID" => "你尚未获取该转账场景,请确认转账场景ID是否正确",
-        "TRANSFER_REMARK_SET_FAIL" => "转账备注设置失败, 请调整后重新再试",
-        "RECEIVE_ACCOUNT_NOT_CONFIGURE" => "请前往商户平台-商家转账到零钱-前往功能-转账场景中添加",
-        "BLOCK_B2C_USERLIMITAMOUNT_BSRULE_MONTH" => "超出用户单月转账收款20w限额,本月不支持继续向该用户付款",
-        "BLOCK_B2C_USERLIMITAMOUNT_MONTH" => "用户账户存在风险收款受限,本月不支持继续向该用户付款",
-        "MERCHANT_REJECT" => "商户员工(转账验密人)已驳回转账",
-        "MERCHANT_NOT_CONFIRM" => "商户员工(转账验密人)超时未验密"
-    ];
-
-
-
-    public static $status = [
-        '待审核',
-        '待打款',
-        '已打款',
-        '无效',
-        '已打款',
-        '已打款',
-        '灵工待打款',
-        '灵工打款失败',
-    ];
-    public static $type = [
-        self::TYPE_WX => '微信',
-        self::TYPE_ALIPAY => '支付宝',
-        self::TYPE_BANK => '银行卡',
-        self::TYPE_RECHARGE => '余额',
-        self::TYPE_LG => '灵工',
-    ];
-
-
-    const WX_CASH_TYPE_OLD = 0;//微信转账类型:0=商家转账到零钱;
-    const WX_CASH_TYPE_NEW = 1;//微信转账类型:1=新版商家转账
-
-    public static $wx_cash_state = [
-        "ACCEPTED" => "转账已受理",
-        "PROCESSING" => "转账处理中",//,转账结果尚未明确,如一直处于此状态,建议检查账户余额是否足够
-        "WAIT_USER_CONFIRM" => "待收款用户确认",//,可拉起微信收款确认页面进行收款确认
-        "TRANSFERING" => "转账结果尚未明确,可拉起微信收款确认页面再次重试确认收款",
-        "SUCCESS" => "转账成功",
-        "FAIL" => "转账失败",
-        "CANCELING" => "商户撤销请求受理成功,该笔转账正在撤销中",
-        "CANCELLED" => "转账撤销完成",
-    ];
-
-
-
-
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
-                ]
-            ]
-        ];
-    }
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['user_id', 'store_id', 'pay_time'], 'required'],
-            [['md_id', 'mch_id', 'user_id', 'saas_id', 'store_id', 'status', 'is_delete', 'created_at', 'pay_time', 'type', 'pay_type', 'cash_type', 'updated_at', 'is_platform_transfers', 'wx_cash_type'], 'integer'],
-            [['price', 'service_charge'], 'number'],
-            [['mobile', 'name', 'order_no', 'bank_branch','lg_refuse_desc'], 'string', 'max' => 255],
-            [['bank_name'], 'string', 'max' => 30],
-            [['wx_cash_state', 'wx_cash_result_info'], 'string']
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'user_id' => '用户id',
-            'saas_id' => '商盟用户id',
-            'store_id' => '商城id',
-            'price' => '提现金额',
-            'status' => '申请状态 0--申请中 1--确认申请 2--已打款 3--驳回  5--余额通过',
-            'is_delete' => '是否删除',
-            'created_at' => '添加時間',
-            'pay_time' => '付款',
-            'type' => '支付方式 0--微信支付  1--支付宝  2--银行卡  3--余额',
-            'mobile' => '支付宝账号',
-            'name' => '支付宝姓名',
-            'bank_name' => '开户行名称',
-            'pay_type' => '打款方式 0--之前未统计的 1--微信自动打款 2--手动打款',
-            'order_no' => '微信自动打款订单号',
-            'service_charge' => '提现手续费',
-            'cash_type' => '0、正常,1、自提点提现',
-            'updated_at' => '更新时间',
-            'bank_branch' => '银行支行',
-        ];
-    }
-
-    public function afterSave($insert, $changedAttributes)
-    {
-        parent::afterSave($insert, $changedAttributes);
-        \app\modules\admin\models\TeamBonusForm::afterCashSave($insert, $changedAttributes, $this);
-
-
-        if ($insert) {
-            $cash_type = '';
-            //分销
-            if ($this->cash_type == self::IS_CASH_TYPE_SHARE) {
-                $cash_type = CashExt::CASH_TYPE_SHARE;
-            }
-            //股东
-            if ($this->cash_type == 3) {
-                $cash_type = CashExt::CASH_TYPE_SHARE_HOLDER;
-            }
-            //区域代理
-            if ($this->cash_type == self::IS_CASH_TYPE_AREA_AGENT) {
-                $cash_type = CashExt::CASH_TYPE_AREA_DIVIDEND;
-            }
-            //团队级差分红
-            if ($this->cash_type == self::IS_CASH_TYPE_TEAM_BONUS) {
-                $cash_type = CashExt::CASH_TYPE_TEAM_BONUS;
-            }
-            //37拼购
-            if ($this->cash_type == self::IS_CASH_TYPE_SHARE_GROUP_PURCHASE) {
-                $cash_type = CashExt::CASH_TYPE_SHARE_GROUP;
-            }
-            //超级卖货系统
-            if ($this->cash_type == self::IS_CASH_TYPE_SUPER_SALES) {
-                $cash_type = CashExt::CASH_TYPE_SUPER_SALES;
-            }
-            //超级卖货系统
-            if ($this->cash_type == self::IS_CASH_TYPE_INTEGRAL_APPRECIATION) {
-                $cash_type = CashExt::CASH_TYPE_INTEGRAL_APPRECIATION;
-            }
-            // 本地公排
-            if ($this->cash_type == self::IS_CASH_TYPE_LOCAL_PUBLIC_RANKING) {
-                $cash_type = CashExt::CASH_TYPE_LOCAL_PUBLIC_RANKING;
-            }
-            if (in_array($cash_type, CashExt::CASH_TYPE_ARR)) {
-                $result = CashExt::cashFront($cash_type, $this->store_id, $this->price,  $this->type);
-                if (!$result['code']) {
-                    $saveResult = CashExt::cashExtSave(
-                        $this->id,
-                        CashExt::CASH_PRICE_TYPE_AMOUNT,
-                        $result['data']['amount_price'],
-                        $result['data']['cash_service_charge'],
-                        $result['data']['real_amount_price']
-                    );
-                    if (isset($saveResult) && $saveResult['code']) {
-                        debug_log($saveResult, 'cashExt.log');
-                    }
-                    $saveResult = CashExt::cashExtSave(
-                        $this->id,
-                        CashExt::CASH_PRICE_TYPE_INTEGRAL,
-                        $result['data']['integral_price'],
-                        $result['data']['cash_service_charge'],
-                        $result['data']['real_integral_price']
-                    );
-                    if (isset($saveResult) && $saveResult['code']) {
-                        debug_log($saveResult, 'cashExt.log');
-                    }
-                    $saveResult = CashExt::cashExtSave(
-                        $this->id,
-                        CashExt::CASH_PRICE_TYPE_BALANCE,
-                        $result['data']['balance_price'],
-                        $result['data']['cash_service_charge'],
-                        $result['data']['real_balance_price']
-                    );
-                    if (isset($saveResult) && $saveResult['code']) {
-                        debug_log($saveResult, 'cashExt.log');
-                    }
-                } else {
-                    debug_log($result, 'cashExt.log');
-                }
-            }
-        }
-        debug_log(['status' => intval($this->status)], '20250520.log');
-        if (in_array(intval($this->status), [self::STATUS_GIVEN, self::STATUS_HAND])) {
-
-
-            debug_log(['cash_type' => $this->cash_type, 'type' => $this->type, 'pay_type' => $this->pay_type], '20250520.log');
-            if ($this->cash_type == self::IS_CASH_TYPE_INTEGRAL_APPRECIATION) {
-                $is_cash_pay = false;
-                // 检测转账成功
-                if (intval($this->status) === self::STATUS_GIVEN) {
-                    if (intval($this->type) === self::TYPE_WX && intval($this->pay_type) === Cash::PAY_TYPE_WX) { //如果是微信支付
-                        if (intval($this->wx_cash_type) === Cash::WX_CASH_TYPE_OLD) {//如果是旧版本微信转账
-                            if ($this->wx_cash_status == Cash::WX_CASH_STATUS_SUCCESS) {
-                                //成功
-                                $is_cash_pay = true;
-                            }
-                        } else {
-                            if (!empty($this->wx_cash_state) && $this->wx_cash_state === 'SUCCESS') {
-                                //成功
-                                $is_cash_pay = true;
-                            }
-                        }
-                    } else {
-                        //成功
-                        $is_cash_pay = true;
-                    }
-                } else {
-                    //成功
-                    $is_cash_pay = true;
-                }
-
-                debug_log(['is_cash_pay' => $is_cash_pay], '20250520.log');
-                if ($is_cash_pay) {
-                    $result = IntegralAppreciationPoolSub::setPool($this->id, $this->store_id, IntegralAppreciationPoolSub::REFLUX_TYPE_WITHDRAW);
-                    debug_log($result, 'integralAppreciationPoolSub.log');
-                }
-            }
-
-
-            $cash_ext_list = CashExt::find()->where(['cash_id' => $this->id, 'is_pay' => 0,
-                'cash_price_type' => [
-                    CashExt::CASH_PRICE_TYPE_INTEGRAL,
-                    CashExt::CASH_PRICE_TYPE_BALANCE
-                ]
-            ])->asArray()->all();
-            foreach ($cash_ext_list as $cash_ext_item) {
-                $type = 1;
-                if ($cash_ext_item['cash_price_type'] == CashExt::CASH_PRICE_TYPE_BALANCE) {
-                    $type = 2;
-                }
-                if ($cash_ext_item['cash_price_type'] == CashExt::CASH_PRICE_TYPE_INTEGRAL) {
-                    $type = 1;
-                }
-               if($cash_ext_item['real_price'] > 0){
-                   $result = AccountLog::saveLog($this->user_id, $cash_ext_item['real_price'], $type, 1, AccountLog::TYPE_CASH, 0, date('Y年m月d日') . "提现申请ID{$this->id}到账");
-                   if ($result) {
-                       $cashExt = CashExt::findOne($cash_ext_item['id']);
-                       $cashExt->is_pay = 1;
-                       $cashExt->save();
-                   }
-               }
-            }
-
-        }
-
-    }
-
-    public static function getServiceMoney($cash)
-    {
-        if($cash['service_charge'] == 0){
-            $price = $cash['price'];
-        }else{
-            $cashPrice = floatval($cash['price']);
-            $price = $cashPrice * (100 - $cash['service_charge']) / 100;
-        }
-        return round($price, 2);
-    }
-    public static function getTypeName($item)
-    {
-        if(($item instanceof self) || is_array($item)){
-            $item = $item['type'];
-        }
-        return self::$type[$item] ?? '';
-    }
-    public static function getStatusName($item)
-    {
-        if(($item instanceof self) || is_array($item)){
-            $item = $item['status'];
-        }
-        return self::$status[$item] ?? '';
-    }
-
-    //获取所有打款状态 (包含微信商家转账到零钱和商家转账功能)
-    public static function getCashStatusName($item) {
-        if (intval($item['type']) === self::TYPE_WX && intval($item['pay_type']) === Cash::PAY_TYPE_WX) { //如果是微信支付
-            if (intval($item['wx_cash_type']) === Cash::WX_CASH_TYPE_OLD) {//如果是旧版本微信转账
-                if (in_array($item['wx_cash_status'], [//判断是否是商家转账到零钱版本
-                    -1,
-                    Cash::WX_CASH_STATUS_INIT,
-                    Cash::WX_CASH_STATUS_FAIL,
-                    Cash::WX_CASH_STATUS_SUCCESS,
-                    Cash::WX_CASH_STATUS_WAIT_PAY,
-                    Cash::WX_CASH_STATUS_PROCESSING
-                ])) {
-                    if (intval($item['wx_cash_status']) === Cash::WX_CASH_STATUS_FAIL) {
-                        return $item['wx_cash_error'];
-                    }
-                    return self::WX_CASH_STATUS_OLD_NAME[$item['wx_cash_status']];
-                }
-            } else {
-                if (!empty($item['wx_cash_state'])) {
-                    return self::$wx_cash_state[$item['wx_cash_state']];
-                }
-            }
-
-        }
-        if (intval($item['pay_type']) === Cash::PAY_TYPE_HAND) {
-            return '后台手动打款';
-        }
-        if (intval($item['pay_type']) === Cash::PAY_TYPE_LG) {
-            if (intval($item['status']) === 3) {
-                return '灵工打款:' . $item['lg_refuse_desc'];
-            }
-            return '灵工打款';
-        }
-
-        return self::$status[$item['status']];
-
-    }
-
-    /**
-     * 分销提现驳回操作 只退款 不修改提现驳回状态
-     * @param $cash_id
-     */
-    public static function cashRefuse($cash_id) {
-        try {
-            $cash = self::findOne($cash_id);
-            $user = User::findOne(['id' => $cash->user_id]);
-            if ($cash->cash_type == Cash::IS_CASH_TYPE_BALANCE) {
-                $saveLog = AccountLog::saveLog($cash->user_id, $cash->price, AccountLog::TYPE_BALANCE, AccountLog::LOG_TYPE_INCOME, 0, 0, "余额提现被驳回,单号:{$cash->order_no}");
-                if (!$saveLog) {
-                    throw new \Exception('余额提现方式驳回失败_');
-                }
-            } elseif ($cash->cash_type == Cash::IS_CASH_TYPE_MCH) {
-                $saveLog = \app\models\MchAccountLog::saveLog($cash->mch_id, $cash->user_id, $cash->price, AccountLog::LOG_TYPE_INCOME, 0, '', "提现被驳回,单号:{$cash->order_no}", 0, 0);
-                if ($saveLog['code']) {
-                    debug_log([
-                        'type' => '店铺内多商户提现',
-                        'error' => $saveLog
-                    ], 'wechat_cash_status.log');
-                }
-            } elseif ($cash->cash_type == Cash::IS_CASH_TYPE_MD) {
-                $md = Md::findOne($cash->md_id);
-                if ($md) {
-                    $md->cash_profit = bcadd($md->cash_profit, $cash->price, 2);
-                    if (!$md->save()) {
-                        throw new \Exception('门店提现_' . json_encode($md->errors, JSON_UNESCAPED_UNICODE));
-                    }
-                }
-            } elseif ($cash->cash_type == Cash::IS_CASH_TYPE_TEAM_GRADES) {
-                $t = \Yii::$app->db->beginTransaction();
-                try {
-                    $user->updateCounters(['price' => $cash->price]);
-                    $teamGrades = TeamGrades::findOne($cash->user_id);
-                    if ($teamGrades) {
-                        $teamGrades->updateCounters(['price' => $cash->price]);
-                    }
-                    $t->commit();
-                } catch (\Exception $e) {
-                    $t->rollBack();
-                    throw new \Exception('团队业绩分红提现_' . $e->getMessage());
-                }
-
-            } elseif ($cash->cash_type == Cash::IS_CASH_TYPE_SHARE_GROUP_PURCHASE) {
-                $t = \Yii::$app->db->beginTransaction();
-                try {
-                    $user->updateCounters(['price' => $cash->price]);
-                    $shareGroupPurchaseUsers = ShareGroupPurchaseUser::findOne(['user_id' => $cash->user_id]);
-                    if ($shareGroupPurchaseUsers) {
-                        $shareGroupPurchaseUsers->updateCounters(['price' => $cash->price]);
-                    }
-                    $t->commit();
-                } catch (\Exception $e) {
-                    $t->rollBack();
-                    throw new \Exception('37拼购分佣提现_' . $e->getMessage());
-                }
-
-            } elseif ($cash->cash_type == Cash::IS_CASH_TYPE_SUPER_SALES) {
-                $t = \Yii::$app->db->beginTransaction();
-                try {
-                    $user->updateCounters(['price' => $cash->price]);
-                    $superSalesUser = SuperSalesUser::findOne(['user_id' => $cash->user_id]);
-                    if ($superSalesUser) {
-                        $superSalesUser->updateCounters(['price' => $cash->price]);
-                    }
-                    $t->commit();
-                } catch (\Exception $e) {
-                    $t->rollBack();
-                    throw new \Exception('超级卖货系统分佣提现_' . $e->getMessage());
-                }
-
-            } elseif ($cash->cash_type == Cash::IS_CASH_TYPE_INTEGRAL_APPRECIATION) {
-                $t = \Yii::$app->db->beginTransaction();
-                try {
-
-                    $cashLog = IntegralAppreciationCashLog::findOne(['cash_id' => $cash->id]);
-                    if ($cashLog) {
-                        $integral_appreciation_user = IntegralAppreciationUser::findOne(['user_id' => $cash->user_id]);
-                        if ($integral_appreciation_user) {
-                            $integral_appreciation_user->updateCounters(['integral' => $cashLog->integral]);
-                            $result = IntegralAppreciationUserIntegralLog::saveIntegralLog($integral_appreciation_user->id, $cashLog->integral, IntegralAppreciationUserIntegralLog::TYPE_INCOME, IntegralAppreciationUserIntegralLog::SOURCE_TYPE_WITHDRAW_FAIL);
-                            if ($result['code']) {
-                                throw new \Exception('积分分佣提现_' . $result['msg']);
-                            }
-                        }
-                    }
-
-                    $t->commit();
-                } catch (\Exception $e) {
-                    $t->rollBack();
-                    throw new \Exception('超级卖货系统分佣提现_' . $e->getMessage());
-                }
-
-            } else {
-                $user->price = bcadd($user->price, $cash->price, 2);
-                if (!$user->save()) {
-                    throw new \Exception('用户佣金增加失败_' . json_encode($user->errors, JSON_UNESCAPED_UNICODE));
-                }
-            }
-            return true;
-        } catch (\Exception $exception) {
-            debug_log([
-                'type' => '用户佣金增加失败',
-                'error' => [
-                    'message' => $exception->getMessage(),
-                    'file' => $exception->getFile(),
-                    'line' => $exception->getLine()
-                ]
-            ], 'wechat_cash_status.log');
-            return false;
-        }
-
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+/**
+ * This is the model class for table "{{%cash}}".
+ *
+ * @property int $id
+ * @property int $user_id 用户id
+ * @property int $store_id 商城id
+ * @property float $price 提现金额
+ * @property int $status 申请状态 0--申请中 1--确认申请 2--已打款 3--驳回  5--余额通过
+ * @property int $is_delete 是否删除
+ * @property int|null $created_at 添加時間
+ * @property int $pay_time 付款
+ * @property int $type 支付方式 0--微信支付  1--支付宝  2--银行卡  3--余额
+ * @property string|null $mobile 支付宝账号
+ * @property string|null $name 支付宝姓名
+ * @property string|null $bank_name 开户行名称
+ * @property string|null $bank_branch 银行支行
+ * @property int|null $pay_type 打款方式 0--之前未统计的 1--微信自动打款 2--手动打款
+ * @property string|null $order_no 微信自动打款订单号
+ * @property float $service_charge 提现手续费
+ * @property int|null $cash_type 0、正常,1、自提点提现
+ * @property int|null $updated_at 更新时间
+ * @property int $md_id 门店id
+ * @property int $wx_cash_status 微信转账状态:0无状态  1转账成功 2转账失败  3待确认 4转账中
+ * @property string $wx_cash_error 微信转账失败错误原因
+ */
+class Cash extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%cash}}';
+    }
+
+    /**
+     * 已删除
+     */
+    const IS_DELETE_YES = 1;
+
+    /**
+     * 未删除
+     */
+    const IS_DELETE_NO = 0;
+
+    /**
+     * 申请中
+     */
+    const STATUS_APPLY = 0;
+
+    /**
+     * 确认申请
+     */
+    const STATUS_CONFIRM = 1;
+
+    /**
+     * 已打款
+     */
+    const STATUS_GIVEN = 2;
+
+    /**
+     * 驳回
+     */
+    const STATUS_REFUSE = 3;
+
+    /**
+     * 手动打款
+     */
+    const STATUS_HAND = 4;
+
+    /**
+     * 余额通过
+     */
+    const STATUS_RECHARGE = 5;
+
+    /**
+     * 微信打款
+     */
+    const TYPE_WX = 0;
+
+    /**
+     * 支付宝打款
+     */
+    const TYPE_ALIPAY = 1;
+
+    /**
+     * 银行卡打款
+     */
+    const TYPE_BANK = 2;
+
+    /**
+     * 余额打款
+     */
+    const TYPE_RECHARGE = 3;
+
+    /**
+     * 之前未统计的
+     */
+    const PAY_TYPE_NO = 0;
+
+    /**
+     * 微信自动打款
+     */
+    const PAY_TYPE_WX = 1;
+
+    /**
+     * 手动拨款
+     */
+    const PAY_TYPE_HAND = 2;
+
+    /**
+     * 分销商
+     */
+    const IS_CASH_TYPE_SHARE = 0;
+    /**
+     * 自提点
+     */
+    const IS_CASH_TYPE_SHOP = 1;
+    /**
+     * 上门服务师傅分佣
+     */
+    const IS_CASH_TYPE_WORKER = 6;
+    /**
+     * 余额提现
+     */
+    const IS_CASH_TYPE_BALANCE = 7;
+    /**
+     * 区域代理佣金提现
+     */
+    const IS_CASH_TYPE_AREA_AGENT = 8;
+    /**
+     * 店铺内多商户提现
+     */
+    const IS_CASH_TYPE_MCH = 9;
+
+
+    const WX_CASH_STATUS_INIT = 0;//初始态。 系统转账校验中
+    const WX_CASH_STATUS_SUCCESS = 1;//成功
+    const WX_CASH_STATUS_FAIL = 2;//失败
+    const WX_CASH_STATUS_WAIT_PAY = 3;//待确认 。待商户确认, 符合免密条件时, 系统会自动扭转为转账中
+    const WX_CASH_STATUS_PROCESSING = 4;//转账中。正在处理中,转账结果尚未明确
+    /**
+     * 微信转账状态
+     */
+    const WX_CASH_STATUS_ARR = [
+        'INIT'  => 0,//初始态。 系统转账校验中
+        'SUCCESS' => 1,//成功
+        'FAIL' => 2,//失败
+        'WAIT_PAY' => 3,//待确认 。待商户确认, 符合免密条件时, 系统会自动扭转为转账中
+        'PROCESSING' => 4,//转账中。正在处理中,转账结果尚未明确
+    ];
+
+    const WX_CASH_FAIL_REASON = [
+        "ACCOUNT_FROZEN" => "该用户账户被冻结",
+        "REAL_NAME_CHECK_FAIL" => "收款人未实名认证,需要用户完成微信实名认证",
+        "NAME_NOT_CORRECT" => "收款人姓名校验不通过,请核实信息",
+        "OPENID_INVALID" => "Openid格式错误或者不属于商家公众账号",
+        "TRANSFER_QUOTA_EXCEED" => "超过用户单笔收款额度,核实产品设置是否准确",
+        "DAY_RECEIVED_QUOTA_EXCEED" => "超过用户单日收款额度,核实产品设置是否准确",
+        "MONTH_RECEIVED_QUOTA_EXCEED" => "超过用户单月收款额度,核实产品设置是否准确",
+        "DAY_RECEIVED_COUNT_EXCEED" => "超过用户单日收款次数,核实产品设置是否准确",
+        "PRODUCT_AUTH_CHECK_FAIL" => "未开通该权限或权限被冻结,请核实产品权限状态",
+        "OVERDUE_CLOSE" => "超过系统重试期,系统自动关闭",
+        "ID_CARD_NOT_CORRECT" => "收款人身份证校验不通过,请核实信息",
+        "ACCOUNT_NOT_EXIST" => "该用户账户不存在",
+        "TRANSFER_RISK" => "该笔转账可能存在风险,已被微信拦截",
+        "OTHER_FAIL_REASON_TYPE" => "其它失败原因",
+        "REALNAME_ACCOUNT_RECEIVED_QUOTA_EXCEED" => "用户账户收款受限,请引导用户在微信支付查看详情",
+        "RECEIVE_ACCOUNT_NOT_PERMMIT" => "未配置该用户为转账收款人,请在产品设置中调整,添加该用户为收款人",
+        "PAYEE_ACCOUNT_ABNORMAL" => "用户账户收款异常,请联系用户完善其在微信支付的身份信息以继续收款",
+        "PAYER_ACCOUNT_ABNORMAL" => "商户账户付款受限,可前往商户平台获取解除功能限制指引",
+        "TRANSFER_SCENE_UNAVAILABLE" => "该转账场景暂不可用,请确认转账场景ID是否正确",
+        "TRANSFER_SCENE_INVALID" => "你尚未获取该转账场景,请确认转账场景ID是否正确",
+        "TRANSFER_REMARK_SET_FAIL" => "转账备注设置失败, 请调整后重新再试",
+        "RECEIVE_ACCOUNT_NOT_CONFIGURE" => "请前往商户平台-商家转账到零钱-前往功能-转账场景中添加",
+        "BLOCK_B2C_USERLIMITAMOUNT_BSRULE_MONTH" => "超出用户单月转账收款20w限额,本月不支持继续向该用户付款",
+        "BLOCK_B2C_USERLIMITAMOUNT_MONTH" => "用户账户存在风险收款受限,本月不支持继续向该用户付款",
+        "MERCHANT_REJECT" => "商户员工(转账验密人)已驳回转账",
+        "MERCHANT_NOT_CONFIRM" => "商户员工(转账验密人)超时未验密"
+    ];
+
+
+
+    public static $status = [
+        '待审核',
+        '待打款',
+        '已打款',
+        '无效',
+        '已打款',
+        '已打款',
+    ];
+    public static $type = [
+        self::TYPE_WX => '微信',
+        self::TYPE_ALIPAY => '支付宝',
+        self::TYPE_BANK => '银行卡',
+        self::TYPE_RECHARGE => '余额',
+    ];
+
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
+                ]
+            ]
+        ];
+    }
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['user_id', 'store_id', 'pay_time'], 'required'],
+            [['md_id', 'mch_id', 'user_id', 'saas_id', 'store_id', 'status', 'is_delete', 'created_at', 'pay_time', 'type', 'pay_type', 'cash_type', 'updated_at'], 'integer'],
+            [['price', 'service_charge'], 'number'],
+            [['mobile', 'name', 'order_no', 'bank_branch'], 'string', 'max' => 255],
+            [['bank_name'], 'string', 'max' => 30],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'user_id' => '用户id',
+            'saas_id' => '商盟用户id',
+            'store_id' => '商城id',
+            'price' => '提现金额',
+            'status' => '申请状态 0--申请中 1--确认申请 2--已打款 3--驳回  5--余额通过',
+            'is_delete' => '是否删除',
+            'created_at' => '添加時間',
+            'pay_time' => '付款',
+            'type' => '支付方式 0--微信支付  1--支付宝  2--银行卡  3--余额',
+            'mobile' => '支付宝账号',
+            'name' => '支付宝姓名',
+            'bank_name' => '开户行名称',
+            'pay_type' => '打款方式 0--之前未统计的 1--微信自动打款 2--手动打款',
+            'order_no' => '微信自动打款订单号',
+            'service_charge' => '提现手续费',
+            'cash_type' => '0、正常,1、自提点提现',
+            'updated_at' => '更新时间',
+            'bank_branch' => '银行支行',
+        ];
+    }
+
+    public static function getServiceMoney($cash)
+    {
+        if($cash['service_charge'] == 0){
+            $price = $cash['price'];
+        }else{
+            $cashPrice = floatval($cash['price']);
+            $price = $cashPrice * (100 - $cash['service_charge']) / 100;
+        }
+        return round($price, 2);
+    }
+    public static function getTypeName($item)
+    {
+        if(($item instanceof self) || is_array($item)){
+            $item = $item['type'];
+        }
+        return self::$type[$item] ?? '';
+    }
+    public static function getStatusName($item)
+    {
+        if(($item instanceof self) || is_array($item)){
+            $item = $item['status'];
+        }
+        return self::$status[$item] ?? '';
+    }
+}

+ 59 - 59
models/CashierGoodsPriceLog.php

@@ -1,59 +1,59 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * This is the model class for table "{{%cashier_goods_price_log}}".
- *
- * @property integer $id
- * @property integer $goods_id
- * @property integer $user_id
- * @property integer $md_id
- * @property string  $attr
- * @property float   $price
- * @property string  $created_at
- */
-class CashierGoodsPriceLog extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%cashier_goods_price_log}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at']
-                ]
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'goods_id', 'user_id', 'md_id'], 'integer'],
-            [['created_at', 'attr'], 'string'],
-            [['price'], 'number'],
-            [['created_at'], 'safe']
-        ];
-    }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "{{%cashier_goods_price_log}}".
+ *
+ * @property integer $id
+ * @property integer $goods_id
+ * @property integer $user_id
+ * @property integer $md_id
+ * @property string  $attr
+ * @property float   $price
+ * @property string  $created_at
+ */
+class CashierGoodsPriceLog extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%cashier_goods_price_log}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at']
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'goods_id', 'user_id', 'md_id'], 'integer'],
+            [['created_at', 'attr'], 'string'],
+            [['price'], 'number'],
+            [['created_at'], 'safe']
+        ];
+    }
+
+}

+ 177 - 172
models/Cat.php

@@ -1,172 +1,177 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use app\jobs\storeSync\DiyCommon;
-use yii\behaviors\TimestampBehavior;
-use yii\db\ActiveRecord;
-
-/**
- * Class Cat
- * @package app\modules\models
- * @property integer $id
- * @property integer $store_id
- * @property integer $parent_id
- * @property string $name
- * @property string $pic_url
- * @property integer $sort
- * @property integer $is_delete
- * @property string $is_show
- * @property integer $shop_count
- * @property string $created_at
- * @property string $updated_at
- */
-class Cat extends ActiveRecord
-{
-    /**
-     * 分类是否显示:显示
-     */
-    const IS_SHOW_TRUE = 1;
-
-    /**
-     * 分类是否显示:不显示
-     */
-    const IS_SHOW_FALSE = 0;
-
-    public function behaviors()
-    {
-        return [
-            [
-                // 自动更新创建和更新时间
-                'class' => TimestampBehavior::class,
-                'value' => time()
-            ]
-        ];
-    }
-
-    public static function tableName()
-    {
-        return '{{%cat}}';
-    }
-
-    public function rules()
-    {
-        return [
-            [['store_id', 'name',], 'required'],
-            [['store_id', 'parent_id', 'sort', 'created_at', 'updated_at', 'is_delete', 'is_show', 'shop_count'], 'integer'],
-            [['pic_url'], 'string'],
-            [['name'], 'string', 'max' => 255],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => '商城id',
-            'parent_id' => '上级分类id',
-            'name' => '分类名称',
-            'pic_url' => '分类图片url',
-            'sort' => '排序,升序',
-            'created_at' => '创建时间',
-            'updated_at' => '更新时间',
-            'is_delete' => 'Is Delete',
-            'is_show' => '是否显示',
-            'shop_count' => '起购数量'
-        ];
-    }
-
-
-    public function afterSave($insert, $changedAttributes)
-    {
-        parent::afterSave($insert, $changedAttributes);
-        \app\modules\admin\models\jushuitan\JuShuiTanForm::afterCatSave($this);
-
-        (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_PRODUCT_CAT, [$this->id]);
-    }
-    /**
-     * 获取所有的分类
-     * @param int $store_id
-     * @param int $parent_id
-     * @return array
-     */
-    public static function getCatList($store_id = 1, $is_show = -1, $parent_id = 0, $getGoods = 1)
-    {
-        // $cat_list_cache_key = 'goods_cat_list_cache_' . $store_id;
-        // if ($list = cache()->get($cat_list_cache_key)) {
-        //     return $list;
-        // }
-        $res = [];
-        $query = self::find()->where([
-            'parent_id' => $parent_id,
-            'is_delete' => 0,
-            'store_id' => $store_id
-        ])->orderBy(['sort'=>SORT_ASC]);
-        if ($is_show > -1) {
-            $query->andWhere([
-                'is_show' => $is_show
-            ]);
-        }
-        $cat_list = $query->asArray()->all();
-        if (empty($cat_list)) {
-            return $res;
-        }
-        foreach ($cat_list as &$val) {
-            $val['children'] = self::getCatList($store_id, $is_show, $val['id'], $getGoods);
-            if($getGoods){
-                $val['children'] = self::getCatList($store_id, $is_show, $val['id']);
-//                $goods_ids = GoodsCat::find()->where(['store_id' => $store_id, 'cat_id' => $val['id'], 'is_delete' => 0])->select('goods_id')->all();
-//                $goods_ids = array_column($goods_ids, 'goods_id');
-//                $val['goods_list'] = Goods::find()->where(['store_id' => $store_id, 'is_delete' => 0, 'status' => 1])->andWhere(['in', 'id', $goods_ids])
-//                    ->select('name, cover_pic, price, original_price, virtual_sales')->all();
-            }
-            $res[] = $val;
-        }
-        // cache()->set($cat_list_cache_key, $res, 600);
-        return $res;
-    }
-   public static function getCatId($parent_id, &$cat_list = [])
-   {
-       $cat_list[] = $parent_id;
-       $query = self::find()->where([
-           'parent_id' => $parent_id,
-           'is_delete' => 0,
-           'store_id' => get_store_id()
-       ])->orderBy(['sort'=>SORT_DESC]);
-       $query->andWhere([
-           'is_show' => 1
-       ]);
-       $cat = $query->asArray()->all();
-       if (empty($cat)) {
-           return $cat_list;
-       }
-       foreach ($cat as &$val) {
-           self::getCatId($val['id'], $cat_list);
-       }
-       return $cat_list;
-   }
-   public static function getCatListByPids($store_id = 0, $pids = []) {
-       $list = self::find()->where([
-           'is_delete' => 0,
-           'is_show' => 1,
-           'store_id' => $store_id
-       ])->orderBy(['sort'=>SORT_ASC])->all();
-       foreach($list as $item){
-           if(in_array($item['parent_id'], $pids)){
-               $pids[] = $item['id'];
-           }
-       }
-       return $pids;
-   }
-
-   public function beforeSave($insert)
-   {
-       \queue_push(new \app\jobs\SyncDiyClassifyJob(['store_id' => $this->store_id]));
-       return parent::beforeSave($insert); // TODO: Change the autogenerated stub
-   }
-
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use app\jobs\storeSync\DiyCommon;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * Class Cat
+ * @package app\modules\models
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $parent_id
+ * @property string $name
+ * @property string $pic_url
+ * @property integer $sort
+ * @property integer $is_delete
+ * @property string $is_show
+ * @property integer $shop_count
+ * @property string $created_at
+ * @property string $updated_at
+ */
+class Cat extends ActiveRecord
+{
+    /**
+     * 分类是否显示:显示
+     */
+    const IS_SHOW_TRUE = 1;
+
+    /**
+     * 分类是否显示:不显示
+     */
+    const IS_SHOW_FALSE = 0;
+
+    public function behaviors()
+    {
+        return [
+            [
+                // 自动更新创建和更新时间
+                'class' => TimestampBehavior::class,
+                'value' => time()
+            ]
+        ];
+    }
+
+    public static function tableName()
+    {
+        return '{{%cat}}';
+    }
+
+    public function rules()
+    {
+        return [
+            [['store_id', 'name',], 'required'],
+            [['store_id', 'parent_id', 'sort', 'created_at', 'updated_at', 'is_delete', 'is_show', 'shop_count'], 'integer'],
+            [['pic_url'], 'string'],
+            [['name'], 'string', 'max' => 255],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => '商城id',
+            'parent_id' => '上级分类id',
+            'name' => '分类名称',
+            'pic_url' => '分类图片url',
+            'sort' => '排序,升序',
+            'created_at' => '创建时间',
+            'updated_at' => '更新时间',
+            'is_delete' => 'Is Delete',
+            'is_show' => '是否显示',
+            'shop_count' => '起购数量'
+        ];
+    }
+
+
+    public function afterSave($insert, $changedAttributes)
+    {
+        parent::afterSave($insert, $changedAttributes);
+        \app\modules\admin\models\jushuitan\JuShuiTanForm::afterCatSave($this);
+
+        (new DiyCommon)->JobBehaviors($this->store_id, StoreSyncExtLog::TYPE_PRODUCT_CAT, [$this->id]);
+    }
+    /**
+     * 获取所有的分类
+     * @param int $store_id
+     * @param int $parent_id
+     * @return array
+     */
+    public static function getCatList($store_id = 1, $is_show = -1, $parent_id = 0, $getGoods = 1)
+    {
+        // $cat_list_cache_key = 'goods_cat_list_cache_' . $store_id;
+        // if ($list = cache()->get($cat_list_cache_key)) {
+        //     return $list;
+        // }
+        $res = [];
+        $query = self::find()->where([
+            'parent_id' => $parent_id,
+            'is_delete' => 0,
+            'store_id' => $store_id
+        ])->orderBy(['sort'=>SORT_ASC]);
+        if ($is_show > -1) {
+            $query->andWhere([
+                'is_show' => $is_show
+            ]);
+        }
+        $cat_list = $query->asArray()->all();
+        if (empty($cat_list)) {
+            return $res;
+        }
+        foreach ($cat_list as &$val) {
+            $val['children'] = self::getCatList($store_id, $is_show, $val['id'], $getGoods);
+            if($val['children']){
+                foreach ($val['children'] as &$v) {
+                    $v['children'] = self::getCatList($store_id, $is_show, $v['id'], $getGoods);
+                }
+            }
+            //if($getGoods){
+              //  $val['children'] = self::getCatList($store_id, $is_show, $val['id']);
+//                $goods_ids = GoodsCat::find()->where(['store_id' => $store_id, 'cat_id' => $val['id'], 'is_delete' => 0])->select('goods_id')->all();
+//                $goods_ids = array_column($goods_ids, 'goods_id');
+//                $val['goods_list'] = Goods::find()->where(['store_id' => $store_id, 'is_delete' => 0, 'status' => 1])->andWhere(['in', 'id', $goods_ids])
+//                    ->select('name, cover_pic, price, original_price, virtual_sales')->all();
+           // }
+            $res[] = $val;
+        }
+        // cache()->set($cat_list_cache_key, $res, 600);
+        return $res;
+    }
+   public static function getCatId($parent_id, &$cat_list = [])
+   {
+       $cat_list[] = $parent_id;
+       $query = self::find()->where([
+           'parent_id' => $parent_id,
+           'is_delete' => 0,
+           'store_id' => get_store_id()
+       ])->orderBy(['sort'=>SORT_DESC]);
+       $query->andWhere([
+           'is_show' => 1
+       ]);
+       $cat = $query->asArray()->all();
+       if (empty($cat)) {
+           return $cat_list;
+       }
+       foreach ($cat as &$val) {
+           self::getCatId($val['id'], $cat_list);
+       }
+       return $cat_list;
+   }
+   public static function getCatListByPids($store_id = 0, $pids = []) {
+       $list = self::find()->where([
+           'is_delete' => 0,
+           'is_show' => 1,
+           'store_id' => $store_id
+       ])->orderBy(['sort'=>SORT_ASC])->all();
+       foreach($list as $item){
+           if(in_array($item['parent_id'], $pids)){
+               $pids[] = $item['id'];
+           }
+       }
+       return $pids;
+   }
+
+   public function beforeSave($insert)
+   {
+       \queue_push(new \app\jobs\SyncDiyClassifyJob(['store_id' => $this->store_id]));
+       return parent::beforeSave($insert); // TODO: Change the autogenerated stub
+   }
+
+}

+ 85 - 85
models/Clerk.php

@@ -1,85 +1,85 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\db\ActiveRecord;
-use yii\behaviors\TimestampBehavior;
-
-/**
- * This is the model class for table "{{%clerk}}".
- *
- * @property int $id 主键
- * @property int $store_id 商城id
- * @property int $user_id 用户id
- * @property int $shop_id 自提点id
- * @property int|null $order_count 核销订单数
- * @property float|null $money_count 核销总额
- * @property int|null $card_count 核销卡券数
- * @property int|null $created_at 添加时间
- * @property int|null $updated_at 更新时间
- * @property int $is_delete 是否删除
- */
-class Clerk extends \yii\db\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%clerk}}';
-    }
-
-    const IS_DELETE_YES = 1;//已删除
-    const IS_DELETE_NO = 0;//未删除
-
-
-
-    public function behaviors()
-    {
-        return [
-            [
-                'class' => TimestampBehavior::class,
-                'attributes' => [
-                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
-                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
-                ]
-            ]
-        ];
-    }
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['user_id', 'shop_id'], 'required'],
-            [['id', 'store_id', 'user_id', 'shop_id', 'order_count', 'card_count', 'created_at', 'updated_at', 'is_delete'], 'integer'],
-            [['money_count'], 'number'],
-            [['id'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => '主键',
-            'store_id' => '商城id',
-            'user_id' => '用户id',
-            'shop_id' => '自提点id',
-            'order_count' => '核销订单数',
-            'money_count' => '核销总额',
-            'card_count' => '核销卡券数',
-            'created_at' => '添加时间',
-            'updated_at' => '更新时间',
-            'is_delete' => '是否删除',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+/**
+ * This is the model class for table "{{%clerk}}".
+ *
+ * @property int $id 主键
+ * @property int $store_id 商城id
+ * @property int $user_id 用户id
+ * @property int $shop_id 自提点id
+ * @property int|null $order_count 核销订单数
+ * @property float|null $money_count 核销总额
+ * @property int|null $card_count 核销卡券数
+ * @property int|null $created_at 添加时间
+ * @property int|null $updated_at 更新时间
+ * @property int $is_delete 是否删除
+ */
+class Clerk extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%clerk}}';
+    }
+
+    const IS_DELETE_YES = 1;//已删除
+    const IS_DELETE_NO = 0;//未删除
+
+
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
+                ]
+            ]
+        ];
+    }
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['user_id', 'shop_id'], 'required'],
+            [['id', 'store_id', 'user_id', 'shop_id', 'order_count', 'card_count', 'created_at', 'updated_at', 'is_delete'], 'integer'],
+            [['money_count'], 'number'],
+            [['id'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => '主键',
+            'store_id' => '商城id',
+            'user_id' => '用户id',
+            'shop_id' => '自提点id',
+            'order_count' => '核销订单数',
+            'money_count' => '核销总额',
+            'card_count' => '核销卡券数',
+            'created_at' => '添加时间',
+            'updated_at' => '更新时间',
+            'is_delete' => '是否删除',
+        ];
+    }
+}

+ 84 - 84
models/Cloud.php

@@ -1,84 +1,84 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-use yii\behaviors\TimestampBehavior;
-use yii\helpers\Json;
-
-/**
- * This is the model class for table "{{%cloud}}".
- *
- * @property integer $id
- * @property integer $store_id
- * @property integer $mch_id
- * @property string $name
- * @property string $cloud_type
- * @property string $cloud_setting
- * @property integer $is_delete
- * @property integer $created_at
- * @property integer $updated_at
- */
-class Cloud extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%cloud}}';
-    }
-
-    public function behaviors()
-    {
-        return [
-            [
-                // 自动更新创建和更新时间
-                'class' => TimestampBehavior::class,
-                'value' => time()
-            ]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['store_id', 'mch_id', 'is_delete', 'created_at', 'updated_at'], 'integer'],
-            [['cloud_setting'], 'string'],
-            [['name', 'cloud_type'], 'string', 'max' => 255],
-            ['mch_id', 'default', 'value' => 0]
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'store_id' => 'Store ID',
-            'mch_id' => '商户主键',
-            'name' => '打印机名称',
-            'cloud_type' => '打印机类型',
-            'cloud_setting' => '打印机设置',
-            'is_delete' => 'Is Delete',
-            'updated_at' => '更新时间',
-            'created_at' => '创建时间'
-        ];
-    }
-
-    public function beforeSave($insert)
-    {
-        return true;
-//        $this->name = Json::encode($this->name);
-//        return parent::beforeSave($insert);
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\helpers\Json;
+
+/**
+ * This is the model class for table "{{%cloud}}".
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $mch_id
+ * @property string $name
+ * @property string $cloud_type
+ * @property string $cloud_setting
+ * @property integer $is_delete
+ * @property integer $created_at
+ * @property integer $updated_at
+ */
+class Cloud extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%cloud}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                // 自动更新创建和更新时间
+                'class' => TimestampBehavior::class,
+                'value' => time()
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'mch_id', 'is_delete', 'created_at', 'updated_at'], 'integer'],
+            [['cloud_setting'], 'string'],
+            [['name', 'cloud_type'], 'string', 'max' => 255],
+            ['mch_id', 'default', 'value' => 0]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID',
+            'mch_id' => '商户主键',
+            'name' => '打印机名称',
+            'cloud_type' => '打印机类型',
+            'cloud_setting' => '打印机设置',
+            'is_delete' => 'Is Delete',
+            'updated_at' => '更新时间',
+            'created_at' => '创建时间'
+        ];
+    }
+
+    public function beforeSave($insert)
+    {
+        return true;
+//        $this->name = Json::encode($this->name);
+//        return parent::beforeSave($insert);
+    }
+}

+ 67 - 67
models/CloudGoodsBind.php

@@ -1,67 +1,67 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%cloud_goods_bind}}".
- *
- * @property integer $id
- * @property integer $cloud_goods_id
- * @property integer $cloud_attr_id
- * @property integer $cloud_supplier_id
- * @property integer $goods_id
- * @property integer $attr_id
- * @property integer $is_delete
- * @property integer $created_at
- */
-class CloudGoodsBind extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%cloud_goods_bind}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['cloud_goods_id', 'cloud_attr_id', 'cloud_supplier_id', 'goods_id', 'store_id'], 'integer'],
-            ['attr_id','validateAttrId']
-        ];
-    }
-    
-    public function validateAttrId(){
-        if(!is_int($this->attr_id)   &&  !is_string($this->attr_id)){
-            $this->addError('attr_id', 'attr_id type error');
-        }
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => 'ID',
-            'cloud_goods_id' => '云仓商品id',
-            'cloud_attr_id' =>  '云仓商品属性id',
-            'cloud_supplier_id' => '云仓供货商id',
-            'store_id' => '店铺id',
-            'goods_id' => '赤店商品id',
-            'attr_id'  => '赤店商品属性id',
-            'is_delete' => 'Is Delete',
-            'created_at' => 'Addtime',
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%cloud_goods_bind}}".
+ *
+ * @property integer $id
+ * @property integer $cloud_goods_id
+ * @property integer $cloud_attr_id
+ * @property integer $cloud_supplier_id
+ * @property integer $goods_id
+ * @property integer $attr_id
+ * @property integer $is_delete
+ * @property integer $created_at
+ */
+class CloudGoodsBind extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%cloud_goods_bind}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['cloud_goods_id', 'cloud_attr_id', 'cloud_supplier_id', 'goods_id', 'store_id'], 'integer'],
+            ['attr_id','validateAttrId']
+        ];
+    }
+    
+    public function validateAttrId(){
+        if(!is_int($this->attr_id)   &&  !is_string($this->attr_id)){
+            $this->addError('attr_id', 'attr_id type error');
+        }
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'cloud_goods_id' => '云仓商品id',
+            'cloud_attr_id' =>  '云仓商品属性id',
+            'cloud_supplier_id' => '云仓供货商id',
+            'store_id' => '店铺id',
+            'goods_id' => '云联储商品id',
+            'attr_id'  => '云联储商品属性id',
+            'is_delete' => 'Is Delete',
+            'created_at' => 'Addtime',
+        ];
+    }
+}

+ 63 - 63
models/CloudGoodsUpdateLog.php

@@ -1,63 +1,63 @@
-<?php
-/**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
-namespace app\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%cloud_goods_update_log}}".
- *
- * @property integer $id
- * @property integer $cloud_goods_id
- * @property integer $goods_id
- * @property integer $store_id
- * @property integer $cloud_supplier_id
- * @property integer $is_update
- * @property integer $is_delete
- * @property integer $created_at
- * @property integer $updated_at
- * @property integer $is_audit
- * @property integer $status
- */
-class CloudGoodsUpdateLog extends \yii\db\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%cloud_goods_update_log}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'cloud_supplier_id', 'cloud_goods_id', 'store_id', 'is_update', 'created_at', 'updated_at', 'is_audit', 'status', 'goods_id'], 'integer']
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'id' => '',
-            'cloud_supplier_id' => '供货商id',
-            'cloud_goods_id' =>  '云仓商品id',
-            'store_id' => '商城id',
-            'is_update' => '是否更新0未更新  1已经更新',
-            'created_at' => '创建记录时间',
-            'updated_at'  => '修改时间',
-            'is_audit' => '商品是否审核0未审核  1已审核',
-            'status' => '原商品是否上架'
-        ];
-    }
-}
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%cloud_goods_update_log}}".
+ *
+ * @property integer $id
+ * @property integer $cloud_goods_id
+ * @property integer $goods_id
+ * @property integer $store_id
+ * @property integer $cloud_supplier_id
+ * @property integer $is_update
+ * @property integer $is_delete
+ * @property integer $created_at
+ * @property integer $updated_at
+ * @property integer $is_audit
+ * @property integer $status
+ */
+class CloudGoodsUpdateLog extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%cloud_goods_update_log}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'cloud_supplier_id', 'cloud_goods_id', 'store_id', 'is_update', 'created_at', 'updated_at', 'is_audit', 'status', 'goods_id'], 'integer']
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => '',
+            'cloud_supplier_id' => '供货商id',
+            'cloud_goods_id' =>  '云仓商品id',
+            'store_id' => '商城id',
+            'is_update' => '是否更新0未更新  1已经更新',
+            'created_at' => '创建记录时间',
+            'updated_at'  => '修改时间',
+            'is_audit' => '商品是否审核0未审核  1已审核',
+            'status' => '原商品是否上架'
+        ];
+    }
+}

+ 62 - 0
models/CloudInventory.php

@@ -0,0 +1,62 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+
+/**
+ *
+ * @property integer $id
+ * @property integer $cat_id
+ * @property integer $store_cat_id
+ * @property integer $store_id
+ * @property integer $saas_id
+ * @property integer $goods_id
+ * @property integer $num
+ * @property string  $attr
+ * @property integer $created_at
+ * @property integer $is_delete
+ */
+class CloudInventory extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%cloud_inventory}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+//            [['cat_id', 'goods_id', 'num','saas_id', 'attr'], 'required'],
+            [[ 'cat_id', 'store_cat_id', 'goods_id','saas_id',  'num', 'is_delete'], 'integer'],
+            [['attr'], 'string'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'cat_id' => '分类id',
+            'store_cat_id' => '店铺分类id',
+            'saas_id' => '商盟用户id',
+            'goods_id' => '商品id',
+            'num' => '商品数量',
+            'attr' => '商品规格',
+            'is_delete' => 'Is Delete',
+        ];
+    }
+
+}

+ 83 - 0
models/CloudInventoryBalanceLog.php

@@ -0,0 +1,83 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+/**
+ * Class CloudInventoryCash
+ * @package app\modules\common\models
+ *
+ * @property integer $id
+ * @property integer $saas_id
+ * @property string $saas_name
+ * @property string $saas_mobile
+ * @property integer $action_id
+ * @property integer $price
+ * @property integer $type
+ * @property integer $status
+ * @property integer $before_price
+ * @property integer $after_price
+ * @property integer $is_frozen
+ * @property integer $is_send
+ * @property integer $pre_balance_send
+ * @property integer $send_time
+ * @property integer $purchase_order_id
+ * @property integer $order_type
+ * @property integer $profit
+ * @property string $desc
+ * @property string $purchase_order_no
+ * @property integer $original_order_id
+ * @property string $original_order_no
+ * @property integer $created_at
+ */
+class CloudInventoryBalanceLog extends \yii\db\ActiveRecord
+{
+    /**
+     * @return string
+     */
+    public static function tableName()
+    {
+        return '{{%cloud_inventory_balance_log}}';
+    }
+    //0、扣库存 1、提现 2、转采购金
+    const ORDER_TYPE_INVENTORY = 0;
+    const ORDER_TYPE_CASH = 1;
+    const ORDER_TYPE_TRANSFER= 2;
+    const TYPE_PURCHASE_CLOUD_INVENTORY_PURCHASE_MONEY = 26;
+
+    public function rules()
+    {
+        return [
+            [['id', 'saas_id', 'action_id','type','status','is_frozen','is_send','pre_balance_send','send_time','purchase_order_id','order_type','created_at','original_order_id'],'integer'],
+            [['desc','saas_name' ,'saas_mobile', 'original_order_no'], 'string']
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'action_id' => '行为用户ID',
+            'saas_id' => '商盟用户id',
+            'price' => '变动金额',
+            'type' => '变动金额类型',
+            'status' => '提现状态',
+            'before_price' => '变动之前余额',
+            'after_price' => '变动之后的余额',
+            'is_frozen' => '是否冻结',
+            'is_send' => '冻结余额是否已发放',
+            'pre_balance_send' => '预发余额是否已发放',
+            'send_time' => '发放时间',
+            'desc' => '备注',
+            'purchase_order_id' => '关联订单ID',
+            'order_type' => '订单类型',
+            'profit' => '手续费',
+            'original_order_id' => '原始订单ID',
+            'original_order_no' => '原始订单编号',
+            'created_at' => '添加时间'
+        ];
+    }
+}

+ 65 - 0
models/CloudInventoryCash.php

@@ -0,0 +1,65 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+/**
+ * Class CloudInventoryCash
+ * @package app\modules\common\models
+ *
+ * @property integer $id
+ * @property integer $saas_id
+ * @property string $saas_name
+ * @property string $saas_mobile
+ * @property integer $price
+ * @property integer $status
+ * @property integer $action_time
+ * @property integer $pay_type
+ * @property string $service_charge
+ * @property integer $cash_type
+ * @property string $account
+ * @property string $name
+ * @property string $bank_name
+ * @property integer $created_at
+
+ */
+class CloudInventoryCash extends \yii\db\ActiveRecord
+{
+    /**
+     * @return string
+     */
+    public static function tableName()
+    {
+        return '{{%cloud_inventory_cash}}';
+    }
+
+    public function rules()
+    {
+        return [
+            [['id', 'saas_id', 'status','action_time','pay_type','cash_type'],'integer'],
+            [['name','bank_name','account' ,'saas_name' ,'saas_mobile'], 'string'],
+            [['service_charge'], 'number']
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'saas_id' => '商盟用户id',
+            'price' => '提现金额',
+            'status' => '提现状态',
+            'action_time' => '处理时间',
+            'pay_type' => '打款类型',
+            'service_charge' => '手续费',
+            'cash_type' => '提现方式',
+            'account' => '账号',
+            'bank_name' => '开户行名称',
+            'created_at' => '添加时间',
+            'name' => '姓名'
+        ];
+    }
+}

+ 49 - 0
models/CloudInventoryCat.php

@@ -0,0 +1,49 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+
+class CloudInventoryCat extends \yii\db\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%cloud_inventory_cart}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['store_id', 'saas_id', 'goods_id', 'attr'], 'required'],
+            [['store_id', 'saas_id', 'goods_id', 'num', 'created_at', 'is_delete'], 'integer'],
+            [['attr'], 'string'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => 'Store ID',
+            'saas_id' => '用户id',
+            'goods_id' => '商品id',
+            'num' => '商品数量',
+            'created_at' => 'created_at',
+            'is_delete' => 'Is Delete',
+            'attr' => '规格',
+        ];
+    }
+
+}

+ 62 - 0
models/CloudInventoryDeductPurchaseMoneyLog.php

@@ -0,0 +1,62 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+/**
+ * Class CloudInventoryDeductPurchaseMoneyLog
+ * @package app\modules\common\models
+ *
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $saas_id
+ * @property string $purchase_money
+ * @property string $level_money
+ * @property string $loss_purchase_money
+ * @property integer $loss_num
+ * @property integer $status
+ * @property integer $order_id
+ * @property string $order_no
+ * @property integer $created_at
+ * @property integer $goods_id
+ * @property string $attr
+ * @property integer $original_order_id
+ * @property string $original_order_no
+ */
+class CloudInventoryDeductPurchaseMoneyLog extends \yii\db\ActiveRecord
+{
+    /**
+     * @return string
+     */
+    public static function tableName()
+    {
+        return '{{%cloud_inventory_deduct_purchase_money_log}}';
+    }
+
+    public function rules()
+    {
+        return [
+            [[ 'store_id','saas_id', 'status','order_id','original_order_id','created_at','purchase_money','loss_purchase_money','level_money','loss_num'],'number'],
+            [['order_no', 'original_order_no'], 'string']
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'store_id' => '店铺id',
+            'saas_id' => '商盟用户id',
+            'purchase_money' => '当前采购金',
+            'loss_purchase_money' => '损失采购金',
+            'level_money' => '会员等级采购金',
+            'loss_num' => '采购数量',
+            'status' => '扣除采购金状态',
+            'order_id' => '关联订单ID',
+            'order_no' => '关联订单编号',
+            'created_at' => '添加时间'
+        ];
+    }
+}

+ 179 - 0
models/CloudInventoryGoods.php

@@ -0,0 +1,179 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use yii\db\ActiveRecord;
+use yii\behaviors\TimestampBehavior;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%md_goods}}".
+ *
+ * @property integer $id
+ * @property integer $user_id
+ * @property integer $store_id
+ * @property integer $goods_id
+ * @property string $name
+ * @property string $pic
+ * @property string $attr
+ * @property integer $price
+ * @property integer $platform_price
+ * @property integer $virtual_sales
+ * @property integer $num
+ * @property integer $cloud_inventory_cat_id
+ * @property integer $created_at
+ * @property integer $updated_at
+ */
+class CloudInventoryGoods extends \yii\db\ActiveRecord
+{
+    //活动价(临时字段)
+    public $activityPrice = 0;
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%cloud_inventory_goods}}';
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'attributes' => [
+                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
+                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
+                ]
+            ]
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['store_id','user_id', 'goods_id', 'virtual_sales', 'cloud_inventory_cat_id', 'num'], 'integer'],
+            [['price','platform_price'], 'number'],
+            [['attr','pic','name'], 'string'],
+            [['created_at', 'updated_at'], 'safe']
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'user_id' => '用户id',
+            'store_id' => '商城id',
+            'goods_id' => '商品id',
+            'name' => '商品名称',
+            'virtual_sales' => '销量',
+            'cloud_inventory_cat_id' => '云库存商品类别',
+            'attr' => '规格',
+            'price' => '售价',
+            'platform_price' => '平台价',
+            'num' => '库存',
+            'pic' => '商品缩略图',
+            'created_at' => '',
+            'updated_at' => ''
+        ];
+    }
+
+    public function beforeSave($insert)
+    {
+        if (parent::beforeSave($insert)) {
+            $goods_price = $this->price;
+            $goods_num = $this->goods_num;
+
+            $this->getPriceNum($goods_price, $goods_num);
+            $this->price = $goods_price;
+            $this->goods_num =  $goods_num;
+            return true;
+        }
+    }
+
+    public function getPriceNum(&$goods_price, &$goods_num) {
+        $attr = $this->attr;
+        if (!empty($attr)) {
+            $num = 0;
+
+            $attr_rows = json_decode($attr, true);
+            foreach ($attr_rows as $attr_row) {
+                $num += intval($attr_row['num']);
+            }
+            $goods_num = $num;
+
+
+
+            $price_arr = array_column($attr_rows, 'price');
+            $goods_price = min($price_arr);
+        }
+    }
+
+    /**
+     * 获取商品可选的规格列表
+     */
+    public function getAttrGroupList($use_attr = 1)
+    {
+        $attr_rows = json_decode($this->attr, true);
+        if (empty($attr_rows)) {
+            return [];
+        }
+        $attr_group_list = [];
+        foreach ($attr_rows as $attr_row) {
+            foreach ($attr_row['attr_list'] as $i => $attr) {
+                $attr_id = $attr['attr_id'];
+                $attr = Attr::findOne(['id' => $attr_id, 'is_delete' => 0]);
+                if (!$attr) {
+                    continue;
+                }
+                $in_list = false;
+                foreach ($attr_group_list as $j => $attr_group) {
+                    if ($attr_group->attr_group_id == $attr->attr_group_id) {
+                        $attr_obj = (object)[
+                            'attr_id' => $attr->id,
+                            'attr_name' => $attr->attr_name,
+                        ];
+                        if (!in_array($attr_obj, $attr_group_list[$j]->attr_list)) {
+                            $attr_group_list[$j]->attr_list[] = $attr_obj;
+                        }
+                        $in_list = true;
+                        continue;
+                    }
+                }
+                if (!$in_list) {
+                    $attr_group = AttrGroup::findOne(['is_delete' => 0, 'id' => $attr->attr_group_id]);
+                    if ($attr_group) {
+                        $attr_group_list[] = (object)[
+                            'attr_group_id' => $attr_group->id,
+                            'attr_group_name' => $attr_group->attr_group_name,
+                            'attr_list' => [
+                                (object)[
+                                    'attr_id' => $attr->id,
+                                    'attr_name' => $attr->attr_name,
+                                ],
+                            ],
+                        ];
+                    }
+                }
+            }
+        }
+        if ((int)$use_attr === 0) {
+            $attr_group_list = [
+                $attr_group_list[0]
+            ];
+        }
+        return $attr_group_list;
+    }
+}

+ 145 - 0
models/CloudInventoryGoodsBind.php

@@ -0,0 +1,145 @@
+<?php
+/**
+ * 厦门云联储网络科技有限公司
+ * https://www.baokuaiyun.com
+ * Copyright (c) 2023 爆块云 All rights reserved.
+ */
+namespace app\models;
+
+use app\jobs\storeSync\DiyCommon;
+use yii\behaviors\TimestampBehavior;
+use yii\db\ActiveRecord;
+
+/**
+ * Class CloudInventoryGoodsBind
+ * @package app\modules\models
+ * @property integer $id
+ * @property integer $store_id
+ * @property integer $cloud_inventory_cat_id
+ * @property integer $cloud_goods_id
+ * @property integer $supplier_id
+ * @property string $name
+ * @property integer $status
+ * @property integer $num
+ * @property string $pic_url
+ * @property string $price
+ * @property string $original_price
+ * @property string $attrs
+ * @property integer $use_attr
+ * @property string $platform_negotiated_price
+ * @property integer $is_delete
+ * @property integer $created_at
+ * @property integer $updated_at
+ */
+class CloudInventoryGoodsBind extends ActiveRecord
+{
+    public function behaviors()
+    {
+        return [
+            [
+                // 自动更新创建和更新时间
+                'class' => TimestampBehavior::class,
+                'value' => time()
+            ]
+        ];
+    }
+
+    public static function tableName()
+    {
+        return '{{%cloud_inventory_goods_bind}}';
+    }
+
+    public function rules()
+    {
+        return [
+            [['store_id', 'cloud_inventory_cat_id','cloud_goods_id',], 'required'],
+            [['store_id', 'cloud_inventory_cat_id', 'cloud_goods_id', 'supplier_id', 'updated_at', 'is_delete', 'status', 'num', 'use_attr'], 'integer'],
+            [['pic_url', 'pic_url', 'price', 'original_price', 'attrs', 'platform_negotiated_price'], 'string'],
+            [['name'], 'string', 'max' => 255],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'store_id' => '商城id',
+            'parent_id' => '上级分类id',
+            'name' => '分类名称',
+            'pic_url' => '分类图片url',
+            'sort' => '排序,升序',
+            'created_at' => '创建时间',
+            'updated_at' => '更新时间',
+            'is_delete' => 'Is Delete',
+            'is_show' => '是否显示'
+        ];
+    }
+
+    public function goodsList($param)
+    {
+        if (empty($param['cat_id']) && !empty($param['parent_id'])){
+            $catIds = CloudInventoryGoodsCat::find()->where(['parent_id' => $param['parent_id']])->select('id')->column();
+            $catIds[] = $param['parent_id'];
+        }elseif (!empty($param['cat_id'])){
+            $catIds[] = $param['cat_id'];
+        }
+        $query = self::find()->where(['is_delete' => 0 ,'status'=> 1]);
+        if (!empty($catIds)) {
+            $query->andWhere(['cloud_inventory_cat_id' => $catIds]);
+        }
+        if ($param['name']) {
+            $query->andWhere(['like', 'name', $param['name']]);
+        }
+        if ($param['store_id']) {
+            $query->andWhere(['store_id'=> $param['store_id']]);
+        }
+        if ($param['id']) {
+            $query->andWhere(['id'=> $param['id']]);
+        }
+        if ($param['cloud_goods_id']) {
+            $query->andWhere(['cloud_goods_id'=> $param['cloud_goods_id']]);
+        }
+        $query->orderBy("id desc");
+        $list = pagination_make($query);
+        $saaUser = get_saas_user();
+        foreach ($list['list'] as &$item){
+            $item["level_infos"] = array();
+            $item['attrs'] = get_attrs_level_price($item['attrs'], $saaUser['cloud_inventory_level']);
+            $attrs = json_decode($item['attrs'],true);
+            $item['cloud_inventory_level_price'] = $attrs[0]['cloud_inventory_level_price'];
+            $item['price'] = $attrs[0]['cloud_inventory_level_price'];
+            if($saaUser['cloud_inventory_level'] == 4){
+                $item["level_infos"][0] = array("name"=>"店老板","price"=> $attrs[0]['cloud_inventory_level_price2']);
+                $item["level_infos"][1] = array("name"=>"高级代理商","price"=>$attrs[0]['cloud_inventory_level_price3']);
+            }
+            if($saaUser['cloud_inventory_level'] == 3){
+                $item["level_infos"][0] = array("name"=>"店老板","price"=> $attrs[0]['cloud_inventory_level_price2']);
+            }
+            $item['sold_num'] =  \Yii::$app->db->createCommand("
+                    SELECT SUM(num) 
+                    FROM cyy_cloud_inventory_order_detail 
+                    WHERE goods_id = :goods_id
+                ", [':goods_id' => $item['cloud_goods_id']])->queryScalar();
+        }
+        $list['count'] = $list['totalCount'];
+        $list['page'] = $list['pageNo'];
+        unset($list['totalCount'],$list['pageNo']);
+        return [
+            'code' => 0,
+            'msg' => 'success',
+            'data' => $list
+        ];
+    }
+
+    /**
+     * @return int
+     */
+    public static function getStoreCatId($storeId,$cloudGoodsId)
+    {
+        $cloudInventoryGoodsBind = self::findOne(['store_id' => $storeId , 'cloud_goods_id' => $cloudGoodsId ]);
+        if (!empty($cloudInventoryGoodsBind)){
+            return $cloudInventoryGoodsBind['cloud_inventory_cat_id'];
+        }
+        return 0;
+    }
+}

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor