| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace addons\Clerk\common\models;
- use addons\Agent\common\enums\AgentEnum;
- use common\components\export\CsvTool;
- use common\enums\DownloadEnum;
- use common\enums\StatusEnum;
- use common\helpers\ArrayHelper;
- use common\models\base\BaseActiveRecord;
- use common\models\common\Download;
- use common\models\mall\MallAddons;
- use common\models\user\User;
- use common\models\user\UserPartitionRelationship;
- use common\models\user\UserTeamStatistics;
- use Exception;
- use Yii;
- class ClerkLog extends BaseActiveRecord
- {
- const VERIFY_ELECTRON_COUPON = 0;//核销电子券
- const VERIFY_MAIN_ORDER = 1;//核销系统主体订单
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_clerk_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id','store_id', 'clerk_id','user_id'], 'required'],
- [['mall_id','store_id', 'clerk_id','user_id', 'status','source_table_id', 'created_at', 'updated_at', 'verify_type'], 'integer'],
- [['mobile','title', 'source_table','pic'], 'string'],
- [['commission','money'], 'number'],
- ];
- }
- public static function setData(array $params)
- {
- try {
- if (!empty($params['id'])) {
- $where = ['id'=> $params['id'],'mall_id' => $params['mall_id'],'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]];
- $model = self::findOne($where);
- if (empty($model)) throw new \Exception('服务不存在或已删除');
- } else {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
- if (!$model->save()) throw new Exception($model->getErrorMessage());
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|