Orderreturn.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "order_return".
  6. *
  7. * @property int $id
  8. * @property string|null $deliveryid
  9. * @property string|null $website
  10. * @property string|null $customer
  11. * @property string|null $delivery
  12. * @property string|null $origin_goodsinfo
  13. * @property string|null $goodsinfo
  14. * @property string|null $usage
  15. * @property string|null $receiptdate
  16. * @property int|null $num
  17. * @property string|null $mark
  18. */
  19. class Orderreturn extends \yii\db\ActiveRecord
  20. {
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public static function tableName()
  25. {
  26. return 'order_return';
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function rules()
  32. {
  33. return [
  34. [[ 'num','shop'], 'integer'],
  35. [['imgs'], 'safe'],
  36. [['imgs'], 'string', 'max' => 255],
  37. [['deliveryid', 'website', 'customer', 'receiptdate','delivery', 'origin_goodsinfo', 'goodsinfo', 'usage', 'mark'], 'string', 'max' => 255],
  38. ];
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function attributeLabels()
  44. {
  45. return [
  46. 'id' => 'ID',
  47. 'deliveryid' => '收到单号',
  48. 'website' => '网站',
  49. 'customer' => '客户',
  50. 'delivery' => '货运',
  51. 'origin_goodsinfo' => '原订单货物详情',
  52. 'goodsinfo' => '货物详情',
  53. 'usage' => '完好程度',
  54. 'receiptdate' => '收货日期',
  55. 'num' => '当天序号',
  56. 'mark' => '备注',
  57. 'shop'=>'店铺'
  58. ];
  59. }
  60. public function afterFind(){
  61. parent::afterFind();
  62. $this->receiptdate=date('Y-m-d',$this->receiptdate);
  63. }
  64. public function beforeValidate(){
  65. is_array($this->imgs) && $this->imgs && $this->imgs = implode(',', $this->imgs);
  66. return $this;
  67. }
  68. public function beforeSave($options = array()){
  69. parent::beforeSave($options);
  70. $this->receiptdate=strtotime(trim($this->receiptdate));
  71. if(empty($this->created_at)){
  72. $this->created_at=time();
  73. }
  74. return $this;
  75. }
  76. }