| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- namespace addons\HiGo\common\models;
- use common\enums\StatusEnum;
- use Yii;
- /**
- * This is the model class for table "{{%addons_higo_merchant_reward_log}}".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $user_id
- * @property string $source
- * @property int $source_table_id
- * @property float $profit_price
- * @property float $profit 商家让利嗨呗数量
- * @property float $destroy 销毁嗨呗数量
- * @property int $platform_account_uid
- * @property float $platform_account_reward 平台指定会员嗨呗数量
- * @property float $remaining_rewards 剩余模式嗨呗数量
- * @property int $status 状态,-1:失效,1:正常,2:冻结
- * @property int $created_at 添加时间戳
- * @property int $updated_at 更新时间戳
- * @property int $handle_status 记录状态:0-等待处理,1-已处理
- * @property string $mch_name 商家名称
- * @property int $mode_status 是否分佣:0-否,1-冻结,2-完成
- * @property float $consumer_hi_value 消费者奖励嗨值基数
- * @property float $merchant_hi_value 商家奖励嗨值基数
- * @property float $send_profit 已发放的嗨呗奖励
- */
- class HigoMerchantRewardLog extends \common\models\base\BaseActiveRecord
- {
- const MODE_STATUS_FAIL = -1;
- const MODE_STATUS_WAIT = 0;
- const MODE_STATUS_FROZEN = 1;
- const MODE_STATUS_FINISH = 2;
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_higo_merchant_reward_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'source_table_id', 'user_id', 'status', 'created_at', 'updated_at','platform_account_uid','handle_status','mode_status'], 'integer'],
- [['profit', 'destroy', 'platform_account_reward', 'remaining_rewards','profit_price','consumer_hi_value','merchant_hi_value','send_profit'], 'number'],
- [['source_table','mch_name'],'string']
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'user_id' => 'User ID',
- 'order_id' => 'Order ID',
- 'profit' => 'Profit',
- 'destroy' => 'Destroy',
- 'platform_account' => 'Platform Account',
- 'remaining_rewards' => 'Remaining Rewards',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- /**
- * 保存数据
- * @Author: zmz
- * @DateTime: 2022/11/19 09:13
- * @Copyright: copyright (c) 2022 广东七件事集团
- * @param array $params
- * @return bool|self
- */
- public static function setData(array $params){
- try{
- if(isset($params['id']) && $params['id']) {
- $model = self::findOne(['id' => $params['id']]);
- if (empty($model)) throw new \Exception('服务不存在或已删除');
- }else{
- $model = new self();
- $model->loadDefaultValues();
- }
- if(!$model->load($params,'') || !$model->save()){
- throw new \Exception($model->getErrorMessage());
- }
- return $model;
- }catch(\Exception $e){
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- /**
- * 检测奖励是否发放过
- * @param $mall_id
- * @param $source_table
- * @param $source_id
- * @return HigoMerchantRewardLog|null
- */
- public static function checkReward($mall_id,$source_table,$source_id)
- {
- $log = self::findOne(['mall_id' => $mall_id,'source_table' => $source_table,'source_table_id' => $source_id,'status' => StatusEnum::ENABLED]);
- return $log;
- }
- }
|