UnionpayRequestLog.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace addons\UnionPay\common\models;
  3. use common\enums\StatusEnum;
  4. use common\models\base\BaseActiveRecord;
  5. use Yii;
  6. /**
  7. * This is the model class for table "qimall_addons_unionpay_request_log".
  8. *
  9. * @property int $id
  10. * @property int $mall_id 商城ID
  11. * @property string $type 类型
  12. * @property string $out_trade_no 订单号
  13. * @property string $oldtrxid 原交易的收银宝平台流水
  14. * @property string $trade_type trade_type
  15. * @property string $randomstr 随机字符
  16. * @property string|null $request_data 请求数据
  17. * @property string|null $response_data 返回数据
  18. * @property int $status 状态
  19. * @property int $updated_at
  20. * @property int $created_at
  21. */
  22. class UnionpayRequestLog extends BaseActiveRecord
  23. {
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public static function tableName()
  28. {
  29. return '{{%addons_unionpay_request_log}}';
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function rules()
  35. {
  36. return [
  37. [['mall_id', 'type'], 'required'],
  38. [['mall_id', 'status', 'updated_at', 'created_at'], 'integer'],
  39. [['request_data', 'response_data'], 'string'],
  40. [['type', 'out_trade_no', 'oldtrxid', 'trade_type'], 'string', 'max' => 255],
  41. [['randomstr'], 'string', 'max' => 32],
  42. ];
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function attributeLabels()
  48. {
  49. return [
  50. 'id' => 'ID',
  51. 'mall_id' => '商城ID',
  52. 'type' => '类型',
  53. 'out_trade_no' => '订单号',
  54. 'oldtrxid' => '原交易的收银宝平台流水',
  55. 'trade_type' => 'trade_type',
  56. 'randomstr' => '随机字符',
  57. 'request_data' => '请求数据',
  58. 'response_data' => '返回数据',
  59. 'status' => '状态',
  60. 'updated_at' => 'Updated At',
  61. 'created_at' => 'Created At',
  62. ];
  63. }
  64. public static function setData(int $mall_id, array $data)
  65. {
  66. $model = new self();
  67. $model->loadDefaultValues();
  68. $model->mall_id = $mall_id;
  69. if (!$model->load($data, '')) throw new \Exception($model->getErrorMessage());
  70. if (!$model->save()) {
  71. Yii::error(';;;;;;;;;;;;;;'.$model->getErrorMessage());
  72. return false;
  73. }
  74. return $model;
  75. }
  76. }