AlipayTransfer.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace common\models\alipay;
  3. use Yii;
  4. use yii\helpers\Json;
  5. /**
  6. * This is the model class for table "qimall_alipay_transfer".
  7. *
  8. * @property int $id 订单id
  9. * @property int $status 状态[-1:删除;0:禁用;1启用]
  10. * @property int $created_at 创建时间
  11. * @property int $updated_at 更新时间
  12. * @property int $mall_id 所属内部系统
  13. * @property string $request 请求数据
  14. * @property string $response 响应数据
  15. * @property string $out_biz_no 单号
  16. * @property string $type 来源
  17. */
  18. class AlipayTransfer extends \common\models\base\BaseActiveRecord
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return 'qimall_alipay_transfer';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['status', 'created_at', 'updated_at', 'mall_id'], 'integer'],
  34. [['request', 'response'], 'required'],
  35. [['request', 'response'], 'string'],
  36. [['out_biz_no'], 'string', 'max' => 36],
  37. [['type'], 'string', 'max' => 255],
  38. ];
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function attributeLabels()
  44. {
  45. return [
  46. 'id' => 'ID',
  47. 'status' => 'Status',
  48. 'created_at' => 'Created At',
  49. 'updated_at' => 'Updated At',
  50. 'mall_id' => 'Mall ID',
  51. 'request' => 'Request',
  52. 'response' => 'Response',
  53. 'out_biz_no' => 'Out Biz No',
  54. ];
  55. }
  56. /**
  57. * 新增记录
  58. * @param int $mall_id
  59. * @param string $out_biz_no
  60. * @param string $type
  61. * @param array $request
  62. * @param array $response
  63. * @return mixed|string|true
  64. */
  65. public static function create(int $mall_id, string $out_biz_no, string $type, array $request, array $response)
  66. {
  67. $model = new AlipayTransfer();
  68. $model->mall_id = $mall_id;
  69. $model->out_biz_no = $out_biz_no;
  70. $model->type = $type;
  71. $model->request = Json::encode($request);
  72. $model->response = Json::encode($response);
  73. if (!$model->save()) {
  74. return $model->getError();
  75. }
  76. return true;
  77. }
  78. }