PurchaseOrder.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use Yii;
  9. /**
  10. * This is the model class for table "{{%purchase_order}}".
  11. *
  12. * @property integer $id
  13. * @property integer $cloud_order_id
  14. * @property integer $store_id
  15. * @property integer $user_id
  16. * @property integer $saas_id
  17. * @property string $order_no
  18. * @property string $total_price
  19. * @property string $pay_price
  20. * @property string $express_price
  21. * @property string $name
  22. * @property string $mobile
  23. * @property string $remark
  24. * @property integer $is_pay
  25. * @property integer $pay_type
  26. * @property integer $pay_time
  27. * @property integer $is_comment
  28. * @property integer $created_at
  29. * @property integer $is_delete
  30. * @property integer $is_sale
  31. * @property integer $is_recycle
  32. * @property string $alipay_trade_no
  33. * @property integer $cancel_examine
  34. * @property integer $cancel_examine_time
  35. * @property integer $province_id
  36. * @property integer $city_id
  37. * @property integer $district_id
  38. * @property integer $centralized_status
  39. * @property integer $trade_status
  40. */
  41. class PurchaseOrder extends \yii\db\ActiveRecord
  42. {
  43. /**
  44. * 订单流转状态:默认
  45. */
  46. const ORDER_FLOW_DEFAULT = -1;
  47. /**
  48. * 订单流转状态:待发货
  49. */
  50. const ORDER_FLOW_NO_SEND = 0;
  51. /**
  52. * 订单流转状态:已取消
  53. */
  54. const ORDER_FLOW_CANCEL = 1;
  55. /**
  56. * 订单流转状态:已发货
  57. */
  58. const ORDER_FLOW_SEND = 2;
  59. /**
  60. * 订单流转状态:已完成
  61. */
  62. const ORDER_FLOW_CONFIRM = 3;
  63. public $valid_order_flow = [
  64. self::ORDER_FLOW_DEFAULT,
  65. self::ORDER_FLOW_NO_SEND,
  66. self::ORDER_FLOW_SEND,
  67. self::ORDER_FLOW_CANCEL,
  68. self::ORDER_FLOW_CONFIRM
  69. ];
  70. /**
  71. * 申请取消订单: 默认
  72. */
  73. const ORDER_APPLY_DELETE_DEFAULT = 0;
  74. /**
  75. * 申请取消订单: 申请中
  76. */
  77. const ORDER_APPLY_DELETE = 1;
  78. /**
  79. * 订单来源 公众号或网站
  80. */
  81. const ORDER_SOURCE_WEB = 1;
  82. /**
  83. * 订单来源 app
  84. */
  85. const ORDER_SOURCE_APP = 2;
  86. /**
  87. * 订单来源 小程序
  88. */
  89. const ORDER_SOURCE_MINI = 3;
  90. /**
  91. * 用户取消类型
  92. */
  93. const CANCEL_USER_TYPE = 0;
  94. /**
  95. * 后台取消类型
  96. */
  97. const CANCEL_BACK_TYPE = 1;
  98. /**
  99. * 是否取消(手动):已取消
  100. */
  101. const IS_DELETE_TRUE = 1;
  102. /**
  103. * 是否取消(手动):未取消
  104. */
  105. const IS_DELETE_FALSE = 0;
  106. /**
  107. * 是否支付:已支付
  108. */
  109. const IS_PAY_TRUE = 1;
  110. /**
  111. * 是否支付:未支付
  112. */
  113. const IS_PAY_FALSE = 0;
  114. /**
  115. * 支付方式:未支付
  116. */
  117. const PAY_TYPE_UNPAID = 0;
  118. /**
  119. * 支付方式:微信支付
  120. */
  121. const PAY_TYPE_WECHAT = 1;
  122. /**
  123. * 支付方式:支付宝支付
  124. */
  125. const PAY_TYPE_ALIPAY = 2;
  126. /**
  127. * 支付方式:余额支付
  128. */
  129. const PAY_TYPE_BALANCE_PAID = 3;
  130. /**
  131. * 订单是否显示:显示
  132. */
  133. const IS_SHOW_TRUE = 1;
  134. /**
  135. * 订单是否显示:不显示
  136. */
  137. const IS_SHOW_FALSE = 0;
  138. /**
  139. * 是否过售后时间:是
  140. */
  141. const IS_SALE_TRUE = 1;
  142. /**
  143. * 是否过售后时间:否
  144. */
  145. const IS_SALE_FALSE = 0;
  146. /**
  147. * @inheritdoc
  148. */
  149. public static function tableName()
  150. {
  151. return '{{%purchase_order}}';
  152. }
  153. /**
  154. * @inheritdoc
  155. */
  156. public function rules()
  157. {
  158. return [
  159. [['store_id', 'user_id', 'order_no'], 'required'],
  160. [['store_id', 'user_id', 'is_pay', 'pay_type', 'pay_time',
  161. 'is_comment', 'created_at', 'is_delete', 'province_id', 'city_id', 'district_id', 'centralized_status'], 'integer'],
  162. [['total_price', 'pay_price'], 'number'],
  163. [['order_no', 'name', 'mobile', 'alipay_trade_no'], 'string', 'max' => 255],
  164. [['remark'], 'string', 'max' => 1000],
  165. [['address', 'address_data', 'send_time', 'express', 'express_no', 'confirm_time', 'apply_delete', 'cloud_order_no',
  166. 'alipay_trade_no','is_sale','is_show','trade_status', 'province_id', 'city_id', 'district_id', 'supplier_id'], 'safe'],
  167. ];
  168. }
  169. /**
  170. * @inheritdoc
  171. */
  172. public function attributeLabels()
  173. {
  174. return [
  175. 'id' => 'ID',
  176. 'store_id' => 'Store ID',
  177. 'user_id' => '用户id',
  178. 'order_no' => '订单号',
  179. 'total_price' => '订单总费用(包含运费)',
  180. 'pay_price' => '实际支付总费用(含运费)',
  181. 'name' => '收货人姓名',
  182. 'mobile' => '收货人手机',
  183. 'address' => '收货地址',
  184. 'address_data' => '收货地址信息,json格式',
  185. 'remark' => '订单备注',
  186. 'is_pay' => '支付状态:0=未支付,1=已支付',
  187. 'pay_type' => '支付方式:1=微信支付',
  188. 'pay_time' => '支付时间',
  189. 'send_time' => '发货时间',
  190. 'express' => '物流公司',
  191. 'express_no' => 'Express No',
  192. 'confirm_time' => '确认收货时间',
  193. 'is_comment' => '是否已评价:0=未评价,1=已评价',
  194. 'apply_delete' => '是否申请取消订单:0=否,1=申请取消订单',
  195. 'created_at' => 'Addtime',
  196. 'is_delete' => 'Is Delete',
  197. 'alipay_trade_no' => '支付宝订单号',
  198. 'is_sale' => '是否超过售后时间',
  199. 'is_show' => '是否显示 0--不显示 1--显示(软删除用)',
  200. 'trade_status' => '订单状态,-1:默认,0:待发货,1:已取消,2:已发货,3:已确认',
  201. 'province_id' => '省id',
  202. 'city_id' => '市id',
  203. 'district_id' => '区id',
  204. 'centralized_status' => '集采订单状态'
  205. ];
  206. }
  207. public function getDetail()
  208. {
  209. return $this->hasMany(PurchaseOrderDetail::className(), ['order_id' => 'id']);
  210. }
  211. public function afterOtherDataSave()
  212. {
  213. \app\modules\admin\models\jushuitan\JuShuiTanForm::afterPurchaseOrderSave($this);
  214. }
  215. public function afterSave($insert, $changedAttributes)
  216. {
  217. \app\modules\admin\models\jushuitan\JuShuiTanForm::afterPurchaseOrderSave($this, $insert, $changedAttributes);
  218. }
  219. }