PaymentTypeRefundStatistics.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace common\models\statistics;
  3. use common\enums\StatusEnum;
  4. use Yii;
  5. /**
  6. * This is the model class for table "qimall_payment_type_refund_statistics".
  7. *
  8. * @property int $id
  9. * @property int $mall_id
  10. * @property int $status 状态[-1:删除;0:禁用;1启用]
  11. * @property int $payment_type 支付方式
  12. * @property string $payment_identifier 数据唯一性标识符(支付方式加具体的支付方法拼接而成,如果是组合支付则用 , 分割,例如:7-WEIXIN_XCX,16-W06-CASHIER)
  13. * @property string $trade_type 聚合支付具体的支付方式
  14. * @property int $is_pay_group
  15. * @property int $created_at
  16. * @property int $updated_at
  17. */
  18. class PaymentTypeRefundStatistics extends \common\models\base\BaseActiveRecord
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return 'qimall_payment_type_refund_statistics';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['mall_id', 'status', 'payment_type', 'is_pay_group', 'created_at', 'updated_at'], 'integer'],
  34. [['payment_identifier'], 'string', 'max' => 255],
  35. [['trade_type'], 'string', 'max' => 100],
  36. ];
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function attributeLabels()
  42. {
  43. return [
  44. 'id' => 'ID',
  45. 'mall_id' => 'Mall ID',
  46. 'status' => 'Status',
  47. 'payment_type' => 'Payment Type',
  48. 'payment_identifier' => 'Payment Identifier',
  49. 'trade_type' => 'Trade Type',
  50. 'is_pay_group' => 'Is Pay Group',
  51. 'created_at' => 'Created At',
  52. 'updated_at' => 'Updated At',
  53. ];
  54. }
  55. /**
  56. * @param array $data
  57. *
  58. * @return self
  59. */
  60. public static function setData(array $data): self
  61. {
  62. $model = self::findOne(['payment_identifier' => $data['payment_identifier'], 'status' => StatusEnum::ENABLED, 'mall_id' => $data['mall_id']]);
  63. if (!$model) {
  64. $model = new self();
  65. $model->loadDefaultValues();
  66. $model->load($data, '');
  67. if (!$model->save()) {
  68. throw new \RuntimeException('数据写入失败');
  69. }
  70. }
  71. return $model;
  72. }
  73. }