ClerkLog.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace addons\Clerk\common\models;
  3. use addons\Agent\common\enums\AgentEnum;
  4. use common\components\export\CsvTool;
  5. use common\enums\DownloadEnum;
  6. use common\enums\StatusEnum;
  7. use common\helpers\ArrayHelper;
  8. use common\models\base\BaseActiveRecord;
  9. use common\models\common\Download;
  10. use common\models\mall\MallAddons;
  11. use common\models\user\User;
  12. use common\models\user\UserPartitionRelationship;
  13. use common\models\user\UserTeamStatistics;
  14. use Exception;
  15. use Yii;
  16. class ClerkLog extends BaseActiveRecord
  17. {
  18. const VERIFY_ELECTRON_COUPON = 0;//核销电子券
  19. const VERIFY_MAIN_ORDER = 1;//核销系统主体订单
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return '{{%addons_clerk_log}}';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['mall_id','store_id', 'clerk_id','user_id'], 'required'],
  34. [['mall_id','store_id', 'clerk_id','user_id', 'status','source_table_id', 'created_at', 'updated_at', 'verify_type'], 'integer'],
  35. [['mobile','title', 'source_table','pic'], 'string'],
  36. [['commission','money'], 'number'],
  37. ];
  38. }
  39. public static function setData(array $params)
  40. {
  41. try {
  42. if (!empty($params['id'])) {
  43. $where = ['id'=> $params['id'],'mall_id' => $params['mall_id'],'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]];
  44. $model = self::findOne($where);
  45. if (empty($model)) throw new \Exception('服务不存在或已删除');
  46. } else {
  47. $model = new self();
  48. $model->loadDefaultValues();
  49. }
  50. if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage());
  51. if (!$model->save()) throw new Exception($model->getErrorMessage());
  52. return $model;
  53. } catch (\Exception $e) {
  54. self::$static_error = $e->getMessage();
  55. return false;
  56. }
  57. }
  58. }