| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace bizHd\custom\models;
- use bizHd\base\models\Base;
- use bizHd\custom\observers\BuyAmountObserver;
- class Custom extends Base
- {
- /**
- * xhCustom 的 buyAmount 变动监听的开关(默认是开启)
- *
- * @var bool
- */
- public $listend = true;
- /**
- * xhCustom 的 $notRecordGrowthAndIntegral 是否执行记录成功值与积分
- *
- * @var bool
- */
- public $recordGrowthAndIntegral = true;
- /**
- * mainId(运行时临时属性,不入库)。
- * 传递必要参数 mainId
- * @var int
- */
- public $mainId = 0;
- /**
- * 关联id(运行时临时属性,不入库)。
- *
- * @var int
- */
- public $relateId = 0;
- /**
- * 关联的表或类别(运行时临时属性,不入库)。
- *
- * 关联的表或类别:0.无关联 1.零售订单 -- 具体请查看 xhUserGrowth表的 relateType 字段
- *
- * @var int
- */
- public $relateType = 0;
- /**
- * 流水事件文案(运行时临时属性,不入库)。
- *
- * 业务侧可在 save() 前赋值,供 BuyAmountObserver 使用。
- *
- * @var string
- */
- public $eventRemark = '';
- /**
- * 操作员工 id(运行时临时属性,不入库)。
- *
- * @var int
- */
- public $staffId = 0;
- /**
- * 操作员工名称(运行时临时属性,不入库)。
- *
- * @var string
- */
- public $staffName = '';
- // 加上了 xhCustom 的 buyAmount 变动监听(观察者模式),并处理了联动增减逻辑 -- 该监听依赖 AR 事件触发(如 $model->save())。
- // 若某处直接用 updateAll()/updateByCondition() 直接改 buyAmount,不会触发该观察者。
- public function behaviors()
- {
- return [
- BuyAmountObserver::class,
- ];
- }
- public static function tableName()
- {
- return 'xhCustom';
- }
- }
|