| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <?php
- /*
- * @Author: chaimeihan 1852293413@qq.com
- * @Date: 2024-08-14 17:02:45
- * @LastEditors: chaimeihan 1852293413@qq.com
- * @LastEditTime: 2024-08-14 17:38:24
- * @FilePath: \PHP\models\StoreMoneyLog.php
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
- namespace app\models;
- use Yii;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- /**
- * This is the model class for table "{{%store_money_log}}".
- */
- class StoreMoneyLog extends \yii\db\ActiveRecord
- {
- /**
- * 收入类型
- */
- const LOG_TYPE_INCOME = 1;
- /**
- * 支出类型
- */
- const LOG_TYPE_EXPEND = 2;
- const STORE_QUOTA = 1; // 店铺总额度
- const STORE_BALANCE = 2; // 店铺剩余额度
- const STORE_WITHDRAWN_CASH = 3; // 店铺已提现额度
- const TYPE_STORE = 0;
- const TYPE_SHARE = 1; // 分销提现
- const TYPE_SHAREHOLDER = 2; // 股东分红提现
- const TYPE_SHOP = 3; // 门店提现
- const TYPE_TWO_ADD_ONE = 4; // 2+1提现
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%store_money_log}}';
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::class,
- 'attributes' => [
- ActiveRecord::EVENT_BEFORE_INSERT => 'created_at',
- ]
- ]
- ];
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [[
- 'type',
- 'store_id',
- 'amount',
- 'desc',
- 'type',
- 'before',
- 'after',
- 'recharge_type'
- ], 'required'],
- [[
- 'type',
- 'recharge_type',
- ], 'integer'],
- [[
- 'type',
- 'amount',
- 'type',
- 'before',
- 'after',
- 'recharge_type',
- 'wechat_type'
- ], 'number'],
- [['desc'], 'string'],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'store_id' => '店铺id',
- 'recharge_type' => '类型:1=收入,2=支出',
- 'type' => '0系统默认 1:分销提现 2:股东分红提现 3:门店提现 4:2+1提现的时候',
- 'amount' => '变动数',
- 'desc' => '变动说明',
- 'before' => '变动前',
- 'after' => '变动后',
- ];
- }
- public static function saveLog($storeId, $rechargeType, $type, $amount, $desc, $before, $after, $wechat_type = -1)
- {
- $log = new static();
- $log->store_id = $storeId;
- $log->recharge_type = $rechargeType;
- $log->type = $type;
- $log->amount = $amount;
- $log->desc = $desc;
- $log->before = $before;
- $log->after = $after;
- $log->wechat_type = $wechat_type;
- if (!$log->save()) {
- return $log->getErrors();
- }
- return true;
- }
- }
|