You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
4.1 KiB

  1. <?php
  2. namespace backend\modules\shop\models\ars;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. use backend\modules\shop\models\ars\OrderGoods;
  6. /**
  7. * This is the model class for table "ats_after_sale".
  8. *
  9. * @property int $id
  10. * @property string $wx_refund_id 微信退款单号
  11. * @property string $after_sale_sn 售后单号
  12. * @property int $user_id 用户id
  13. * @property int $order_goods_id 订单商品id
  14. * @property int $amount 退货时实际退的金额
  15. * @property int $count 退换货的商品数量
  16. * @property int $apply_at 申请时间
  17. * @property int $dealt_at 处理时间
  18. * @property int $finish_at 完成时间
  19. * @property int $operator_id 操作者
  20. * @property int $refund_type 退款类型:1:全额退款;2:部分退款
  21. * @property string $description 描述
  22. * @property string $image 图片
  23. * @property int $status 处理状态:0:未处理;1:已同意,待买家确认;2:用户已确认;3:已拒绝;4:退款成功;5:已取消;
  24. * @property int $reason 退换货理由
  25. * @property string $remarks 店家备注
  26. * @property string $take_shipping_sn 用户发货物流单号
  27. * @property int $refund_mode 退款方式:1:仅退款;2:退货退款;
  28. */
  29. class AfterSale extends \yii\db\ActiveRecord
  30. {
  31. public $order_pay_amount; //订单支付金额
  32. //退款类型
  33. const REFUND_TYPE_ALL = 1; //全额退款
  34. const REFUND_TYPE_PART = 2; //部分退款
  35. //处理状态
  36. const STATUS_UNTREATED = 0; //未处理
  37. const STATUS_ACCEPT = 1; //已同意,待买家确认
  38. const STATUS_CONFIRM = 2; //用户已确认
  39. const STATUS_REJECT = 3; //已拒绝
  40. const STATUS_FINISH = 4; //退款成功
  41. const STATUS_CANCEL = 5; //已取消
  42. //退款方式
  43. const REFUND_MODE_MONEY = 1; //仅退款
  44. const REFUND_MODE_MONEY_GOODS = 2; //退货退款
  45. public static $refundType = [
  46. self::REFUND_TYPE_ALL => '全额退款',
  47. self::REFUND_TYPE_PART => '部分退款'
  48. ];
  49. public static $status = [
  50. self::STATUS_UNTREATED => '未处理',
  51. self::STATUS_ACCEPT => '已同意,待买家确认',
  52. self::STATUS_CONFIRM => '用户已确认',
  53. self::STATUS_REJECT => '已拒绝',
  54. self::STATUS_FINISH => '退款成功',
  55. self::STATUS_CANCEL => '已取消'
  56. ];
  57. public static $refundMode = [
  58. self::REFUND_MODE_MONEY => '仅退款',
  59. self::REFUND_MODE_MONEY_GOODS => '退货退款'
  60. ];
  61. /**
  62. * {@inheritdoc}
  63. */
  64. public static function tableName()
  65. {
  66. return 'ats_after_sale';
  67. }
  68. /**
  69. * {@inheritdoc}
  70. */
  71. public function rules()
  72. {
  73. return [
  74. [['user_id', 'order_goods_id', 'amount', 'count', 'apply_at', 'dealt_at', 'finish_at', 'operator_id', 'refund_type', 'status', 'reason', 'refund_mode'], 'integer'],
  75. [['description', 'image', 'remarks'], 'string'],
  76. [['wx_refund_id', 'after_sale_sn'], 'string', 'max' => 64],
  77. [['take_shipping_sn'], 'string', 'max' => 50],
  78. ];
  79. }
  80. /**
  81. * {@inheritdoc}
  82. */
  83. public function attributeLabels()
  84. {
  85. return [
  86. 'id' => 'id',
  87. 'wx_refund_id' => '微信退款单号',
  88. 'after_sale_sn' => '售后单号',
  89. 'user_id' => '用户id',
  90. 'order_goods_id' => '订单商品id',
  91. 'amount' => '退货时实际退的金额',
  92. 'count' => '退货的商品数量',
  93. 'apply_at' => '申请时间',
  94. 'dealt_at' => '处理时间',
  95. 'finish_at' => '完成时间',
  96. 'operator_id' => '操作者',
  97. 'refund_type' => '退款类型',
  98. 'description' => '描述',
  99. 'image' => '图片',
  100. 'status' => '处理状态',
  101. 'reason' => '退换货理由',
  102. 'remarks' => '店家备注',
  103. 'take_shipping_sn' => '用户发货物流单号',
  104. 'refund_mode' => '退款方式',
  105. ];
  106. }
  107. public function getGoods()
  108. {
  109. return $this->hasOne(OrderGoods::className(), ['id' => 'order_goods_id']);
  110. }
  111. }