TaxOrderBook.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace addons\AvoidTax\common\models;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%addons_tax_order_book}}".
  6. *
  7. * @property int $id
  8. * @property int|null $mall_id
  9. * @property int|null $order_id
  10. * @property string|null $out_biz_no 订单号
  11. * @property string|null $identity 记账本
  12. * @property string|null $agreement_no 支付宝系统中用以唯一标识用户签约记录的编号
  13. * @property float|null $amount
  14. * @property int|null $created_at
  15. */
  16. class TaxOrderBook extends \yii\db\ActiveRecord
  17. {
  18. const PREFIX = 'book_';
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public static function tableName()
  23. {
  24. return '{{%addons_tax_order_book}}';
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function rules()
  30. {
  31. return [
  32. [['mall_id', 'order_id', 'created_at'], 'integer'],
  33. [['amount'], 'number'],
  34. [['out_biz_no', 'identity', 'agreement_no'], 'string', 'max' => 64],
  35. ];
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function attributeLabels()
  41. {
  42. return [
  43. 'id' => 'ID',
  44. 'mall_id' => 'Mall ID',
  45. 'order_id' => 'Order ID',
  46. 'out_biz_no' => 'Out Biz No',
  47. 'identity' => 'Identity',
  48. 'agreement_no' => 'Agreement No',
  49. 'amount' => 'Amount',
  50. 'created_at' => 'Created At',
  51. ];
  52. }
  53. public static function getBookNo($no)
  54. {
  55. return self::PREFIX . $no;
  56. }
  57. public static function addOrder($data)
  58. {
  59. array_merge($data, [
  60. 'created_at' => time(),
  61. ]);
  62. $model = new self;
  63. $model->load($data, '');
  64. return $model->save();
  65. }
  66. }