OrderPospal.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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. use Codeception\PHPUnit\ResultPrinter\HTML;
  10. /**
  11. * This is the model class for table "{{%order_pospal}}".
  12. *
  13. * @property integer $id
  14. * @property integer $store_id
  15. * @property integer $user_id
  16. * @property string $order_no
  17. * @property string $total_price
  18. * @property string $pay_price
  19. * @property string $express_price
  20. * @property string $name
  21. * @property string $mobile
  22. * @property string $address
  23. * @property string $remark
  24. * @property integer $is_pay
  25. * @property integer $pay_type
  26. * @property integer $pay_time
  27. * @property integer $send_time
  28. * @property string $express
  29. * @property string $express_no
  30. * @property integer $confirm_time
  31. * @property integer $is_comment
  32. * @property integer $apply_delete
  33. * @property integer $created_at
  34. * @property integer $is_delete
  35. * @property integer $is_price
  36. * @property integer $parent_id
  37. * @property string $first_price
  38. * @property string $second_price
  39. * @property string $third_price
  40. * @property string $coupon_sub_price
  41. * @property string $content
  42. * @property integer $is_offline
  43. * @property integer $clerk_id
  44. * @property string $address_data
  45. * @property string $offline_qrcode
  46. * @property string $before_update_price
  47. * @property integer $shop_id
  48. * @property string $discount
  49. * @property integer $user_coupon_id
  50. * @property string $integral
  51. * @property integer $give_integral
  52. * @property integer $parent_id_1
  53. * @property integer $parent_id_2
  54. * @property integer $is_sale
  55. * @property string $words
  56. * @property string $version
  57. * @property string $express_price_1
  58. * @property integer $mch_id
  59. * @property integer $is_recycle
  60. * @property string $seller_comments
  61. * @property integer $order_union_id
  62. * @property string $rebate
  63. * @property string $before_update_express
  64. * @property integer $is_transfer
  65. * @property integer $type
  66. * @property string $share_price
  67. * @property integer $is_show
  68. * @property integer $order_origin
  69. * @property integer $is_open_offline
  70. * @property integer $trade_status
  71. * @property string $transaction_id
  72. * @property string $alipay_trade_no
  73. * @property string $is_platform
  74. * @property integer $combine_money
  75. * @property integer $is_combine_pay
  76. * @property integer $order_type
  77. * @property string $book_info
  78. * @property string $updated_at
  79. * @property string $is_delivery
  80. * @property integer $md_id
  81. * @property integer $is_trans
  82. * @property integer $profit
  83. * @property integer $province_id
  84. * @property integer $city_id
  85. * @property integer $district_id
  86. * @property integer $food_flag_id
  87. * @property integer $food_book_ext
  88. * @property integer $pay_user_id
  89. * @property string $food_code
  90. * @property integer $ag_rebate
  91. * @property integer $verify_card_id
  92. * @property integer $holder_first_price
  93. * @property integer $holder_second_price
  94. * @property integer $holder_third_price
  95. * @property integer $holder_is_price
  96. * @property integer $share_send_type
  97. * @property integer $share_order_profit
  98. * @property integer $limit_id
  99. * @property integer $limit_price
  100. * @property integer $is_send_limit
  101. * @property integer $old_holder_first_price
  102. * @property integer $old_holder_second_price
  103. * @property integer $old_holder_third_price
  104. * @property integer $old_parent_id
  105. * @property integer $old_parent_id_1
  106. * @property integer $old_parent_id_2
  107. */
  108. class OrderPospal extends \yii\db\ActiveRecord
  109. {
  110. /**
  111. * 订单流转状态:默认
  112. */
  113. const ORDER_FLOW_DEFAULT = -1;
  114. /**
  115. * 订单流转状态:待发货
  116. */
  117. const ORDER_FLOW_NO_SEND = 0;
  118. /**
  119. * 订单流转状态:已取消
  120. */
  121. const ORDER_FLOW_CANCEL = 1;
  122. /**
  123. * 订单流转状态:已发货
  124. */
  125. const ORDER_FLOW_SEND = 2;
  126. /**
  127. * 订单流转状态:已完成
  128. */
  129. const ORDER_FLOW_CONFIRM = 3;
  130. public $valid_order_flow = [
  131. self::ORDER_FLOW_DEFAULT,
  132. self::ORDER_FLOW_NO_SEND,
  133. self::ORDER_FLOW_SEND,
  134. self::ORDER_FLOW_CANCEL,
  135. self::ORDER_FLOW_CONFIRM
  136. ];
  137. /**
  138. * 申请取消订单: 默认
  139. */
  140. const ORDER_APPLY_DELETE_DEFAULT = 0;
  141. /**
  142. * 申请取消订单: 申请中
  143. */
  144. const ORDER_APPLY_DELETE = 1;
  145. /**
  146. * 订单来源 公众号或网站
  147. */
  148. const ORDER_SOURCE_WEB = 1;
  149. /**
  150. * 订单来源 app
  151. */
  152. const ORDER_SOURCE_APP = 2;
  153. /**
  154. * 订单来源 小程序
  155. */
  156. const ORDER_SOURCE_MINI = 3;
  157. /**
  158. * 用户取消类型
  159. */
  160. const CANCEL_USER_TYPE = 0;
  161. /**
  162. * 后台取消类型
  163. */
  164. const CANCEL_BACK_TYPE = 1;
  165. /**
  166. * 是否取消(手动):已取消
  167. */
  168. const IS_DELETE_TRUE = 1;
  169. /**
  170. * 是否取消(手动):未取消
  171. */
  172. const IS_DELETE_FALSE = 0;
  173. /**
  174. * 是否支付:已支付
  175. */
  176. const IS_PAY_TRUE = 1;
  177. /**
  178. * 是否支付:未支付
  179. */
  180. const IS_PAY_FALSE = 0;
  181. /**
  182. * 支付方式:未支付
  183. */
  184. const PAY_TYPE_UNPAID = 0;
  185. /**
  186. * 支付方式:微信支付
  187. */
  188. const PAY_TYPE_WECHAT = 1;
  189. /**
  190. * 支付方式:货到付款
  191. */
  192. const PAY_TYPE_COD = 2;
  193. /**
  194. * 支付方式:余额支付
  195. */
  196. const PAY_TYPE_BALANCE_PAID = 3;
  197. /**
  198. * 订单类型:商城订单
  199. */
  200. const ORDER_TYPE_STORE = 0;
  201. /**
  202. * 订单类型:当面付订单
  203. */
  204. const ORDER_TYPE_POND = 1;
  205. /**
  206. * 订单类型:认养订单
  207. */
  208. const ORDER_TYPE_Adopt = 5;
  209. /**
  210. * 订单是否显示:显示
  211. */
  212. const IS_SHOW_TRUE = 1;
  213. /**
  214. * 订单是否显示:不显示
  215. */
  216. const IS_SHOW_FALSE = 0;
  217. /**
  218. * 是否过售后时间:是
  219. */
  220. const IS_SALE_TRUE = 1;
  221. /**
  222. * 是否过售后时间:否
  223. */
  224. const IS_SALE_FALSE = 0;
  225. /**
  226. * 自提订单
  227. */
  228. const IS_OFFLINE_TRUE = 1;
  229. const IS_OFFLINE_FALSE = 0;
  230. /**
  231. * 类型
  232. */
  233. // const SEND_TYPE_DADA = 1;
  234. // const SEND_TYPE_UU = 2;
  235. // const SEND_TYPE_PEISONG = 3;
  236. /**
  237. * 同城配送
  238. */
  239. const IS_SAME_CITY_NO = 0; //否
  240. const IS_SAME_CITY_YES = 1; //是
  241. /**
  242. * 是否是组合支付:是
  243. */
  244. const IS_COMBINE_PAY = 1;
  245. /**
  246. * 是否是组合支付:否
  247. */
  248. const NOT_COMBINE_PAY = 0;
  249. /**
  250. * @inheritdoc
  251. */
  252. public static function tableName()
  253. {
  254. return '{{%order_pospal}}';
  255. }
  256. /**
  257. * @inheritdoc
  258. */
  259. public function rules()
  260. {
  261. return [
  262. [['store_id', 'user_id', 'order_no', 'first_price', 'second_price', 'third_price'], 'required'],
  263. [['store_id', 'user_id', 'is_pay', 'pay_type', 'pay_time', 'send_time',
  264. 'confirm_time', 'is_comment', 'apply_delete', 'created_at', 'updated_at', 'is_delete', 'is_price', 'parent_id',
  265. 'is_offline', 'clerk_id', 'shop_id', 'user_coupon_id', 'give_integral', 'parent_id_1',
  266. 'parent_id_2', 'old_parent_id', 'old_parent_id_1', 'old_parent_id_2', 'is_sale', 'mch_id', 'order_union_id', 'is_transfer', 'type', 'is_show',
  267. 'is_open_offline', 'order_origin', 'trade_status', 'is_platform', 'is_combine_pay', 'order_type',
  268. 'is_delivery', 'md_id', 'is_trans', 'province_id', 'city_id', 'district_id', 'food_flag_id', 'pay_user_id', 'verify_card_id', 'holder_is_price', 'share_send_type','limit_id', 'is_send_limit','integral_price'], 'integer'],
  269. [['total_price', 'pay_price', 'express_price', 'first_price', 'second_price', 'third_price',
  270. 'coupon_sub_price', 'before_update_price', 'discount', 'express_price_1', 'rebate',
  271. 'before_update_express', 'share_price', 'combine_money', 'profit', 'ag_rebate', 'holder_first_price', 'holder_second_price', 'holder_third_price', 'old_holder_first_price', 'old_holder_second_price', 'old_holder_third_price', 'share_order_profit', 'limit_price','integral_difference_price'], 'number'],
  272. [['address_data', 'content', 'offline_qrcode', 'integral', 'words', 'seller_comments', 'book_info', 'food_book_ext', 'food_code'], 'string'],
  273. [['order_no', 'name', 'mobile', 'express', 'express_no', 'version', 'alipay_trade_no'], 'string', 'max' => 255],
  274. [['address', 'remark'], 'string', 'max' => 1000],
  275. ];
  276. }
  277. /**
  278. * @inheritdoc
  279. */
  280. public function attributeLabels()
  281. {
  282. return [
  283. 'id' => 'ID',
  284. 'store_id' => 'Store ID',
  285. 'user_id' => '用户id',
  286. 'order_no' => '订单号',
  287. 'total_price' => '订单总费用(包含运费)',
  288. 'pay_price' => '实际支付总费用(含运费)',
  289. 'express_price' => '运费',
  290. 'integral_price' => '积分数量',
  291. 'integral_difference_price' => '补积分差价',
  292. 'name' => '收货人姓名',
  293. 'mobile' => '收货人手机',
  294. 'address' => '收货地址',
  295. 'remark' => '订单备注',
  296. 'is_pay' => '支付状态:0=未支付,1=已支付',
  297. 'pay_type' => '支付方式:1=微信支付',
  298. 'pay_time' => '支付时间',
  299. 'send_time' => '发货时间',
  300. 'express' => '物流公司',
  301. 'express_no' => 'Express No',
  302. 'confirm_time' => '确认收货时间',
  303. 'is_comment' => '是否已评价:0=未评价,1=已评价',
  304. 'apply_delete' => '是否申请取消订单:0=否,1=申请取消订单',
  305. 'created_at' => 'Addtime',
  306. 'is_delete' => 'Is Delete',
  307. 'is_price' => '是否发放佣金',
  308. 'parent_id' => '用户上级ID',
  309. 'first_price' => '一级佣金',
  310. 'second_price' => '二级佣金',
  311. 'third_price' => '三级佣金',
  312. 'coupon_sub_price' => '优惠券抵消金额',
  313. 'content' => 'Content',
  314. 'is_offline' => '是否到店自提 0--否 1--是',
  315. 'clerk_id' => '核销员user_id',
  316. 'address_data' => '收货地址信息,json格式',
  317. 'offline_qrcode' => '核销码',
  318. 'before_update_price' => '修改前的价格',
  319. 'shop_id' => '自提自提点ID',
  320. 'discount' => '会员折扣',
  321. 'user_coupon_id' => '使用的优惠券ID',
  322. 'integral' => '积分使用',
  323. 'give_integral' => '是否发放积分【1=> 已发放 , 0=> 未发放】',
  324. 'parent_id_1' => '用户上二级ID',
  325. 'parent_id_2' => '用户上三级ID',
  326. 'is_sale' => '是否超过售后时间',
  327. 'words' => '商家留言',
  328. 'version' => '版本',
  329. 'express_price_1' => '减免的运费',
  330. 'mch_id' => '入驻商户id',
  331. 'seller_comments' => '商家备注',
  332. 'order_union_id' => '合并订单的id',
  333. 'rebate' => '自购返利',
  334. 'before_update_express' => '价格修改前的运费',
  335. 'is_transfer' => '是否已转入商户账户:0=否,1=是',
  336. 'type' => '0普通订单1卡券兑换订单',
  337. 'share_price' => '发放佣金的金额',
  338. 'is_show' => '是否显示 0--不显示 1--显示(软删除用)',
  339. 'order_origin' => '订单来源 1:公众号或者网站 2:app 3:小程序',
  340. 'is_open_offline' => '是否是线下购物车下的订单',
  341. 'trade_status' => '订单状态,-1:默认,0:待发货,1:已取消,2:已发货,3:已确认',
  342. "limit_id"=>"临时关系ID",
  343. 'limit_price' => "临时绑定关系订单佣金",
  344. 'is_send_limit' => "是否发放临时关系佣金"
  345. ];
  346. }
  347. public function getOrderPospalDetail()
  348. {
  349. return $this->hasMany(OrderPospalDetail::className(), ['order_id' => 'id'])->alias('od')
  350. ->leftJoin(['g' => Goods::tableName()], 'g.id=od.goods_id')->select(['od.*', 'g.name', 'g.attr goods_attr', 'g.cost_price']);
  351. }
  352. public function getDetail()
  353. {
  354. return $this->hasMany(OrderPospalDetail::className(), ['order_id' => 'id']);
  355. }
  356. public function getGoods()
  357. {
  358. return $this->hasMany(Goods::className(), ['id' => 'goods_id'])->alias('g')
  359. ->viaTable(OrderPospalDetail::tableName() . ' od', ['order_id' => 'id']);
  360. }
  361. public function getShop()
  362. {
  363. return $this->hasOne(Shop::className(), ['id' => 'shop_id']);
  364. }
  365. public function getClerk()
  366. {
  367. return $this->hasOne(User::className(), ['id' => 'clerk_id']);
  368. }
  369. public function getOrderForm()
  370. {
  371. return $this->hasMany(OrderForm::className(), ['order_id' => 'id'])->where(['is_delete' => 0]);
  372. }
  373. public function getUser()
  374. {
  375. return $this->hasOne(User::className(), ['id' => 'user_id']);
  376. }
  377. public function getRefund()
  378. {
  379. return $this->hasMany(OrderRefund::className(), ['order_id' => 'id']);
  380. }
  381. public function beforeSave($insert)
  382. {
  383. $this->content = \yii\helpers\Html::encode($this->content);
  384. return parent::beforeSave($insert);
  385. }
  386. public function getPondDetail()
  387. {
  388. return $this->hasOne(OrderPospalDetail::className(), ['order_id' => 'id']);
  389. }
  390. public function getPondGoods()
  391. {
  392. return $this->hasOne(Goods::className(), ['id' => 'goods_id'])->alias('g')
  393. ->viaTable(OrderPospalDetail::tableName() . ' od', ['order_id' => 'id']);
  394. }
  395. public function getReceiver(){
  396. return $this->hasOne(SharingReceiver::className(),['order_no'=>'order_no']);
  397. }
  398. public function getStore(){
  399. return $this->hasOne(Store::className(),['id'=>'store_id']);
  400. }
  401. }