AdoptCostOrder.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\plugins\adopt\models;
  8. use Yii;
  9. use Codeception\PHPUnit\ResultPrinter\HTML;
  10. /**
  11. * This is the model class for table "{{%adopt_cost_order}}".
  12. *
  13. * @property integer $id
  14. * @property integer $store_id
  15. * @property integer $order_id
  16. * @property integer $user_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 $address
  24. * @property string $remark
  25. * @property integer $is_pay
  26. * @property integer $pay_type
  27. * @property integer $pay_time
  28. * @property integer $send_time
  29. * @property string $express
  30. * @property string $express_no
  31. * @property integer $confirm_time
  32. * @property integer $apply_delete
  33. * @property integer $created_at
  34. * @property integer $is_delete
  35. * @property string $coupon_sub_price
  36. * @property string $content
  37. * @property integer $is_offline
  38. * @property integer $clerk_id
  39. * @property string $address_data
  40. * @property string $offline_qrcode
  41. * @property string $before_update_price
  42. * @property integer $shop_id
  43. * @property string $discount
  44. * @property integer $user_coupon_id
  45. * @property string $integral
  46. * @property integer $give_integral
  47. * @property integer $is_sale
  48. * @property string $words
  49. * @property string $version
  50. * @property string $express_price_1
  51. * @property integer $mch_id
  52. * @property integer $is_recycle
  53. * @property string $seller_comments
  54. * @property string $before_update_express
  55. * @property integer $is_transfer
  56. * @property integer $is_show
  57. * @property integer $order_origin
  58. * @property integer $is_open_offline
  59. * @property integer $trade_status
  60. * @property string $transaction_id
  61. * @property string $alipay_trade_no
  62. * @property string $is_platform
  63. * @property integer $combine_money
  64. * @property integer $is_combine_pay
  65. * @property integer $order_type
  66. * @property string $updated_at
  67. * @property string $is_delivery
  68. * @property integer $md_id
  69. * @property integer $is_trans
  70. * @property integer $profit
  71. * @property integer $province_id
  72. * @property integer $city_id
  73. * @property integer $district_id
  74. * @property integer $pay_user_id
  75. * @property integer $weight
  76. * @property string $cost_detail
  77. * @property string $order_union_id
  78. */
  79. class AdoptCostOrder extends \yii\db\ActiveRecord
  80. {
  81. /**
  82. * 订单流转状态:默认
  83. */
  84. const ORDER_FLOW_DEFAULT = -1;
  85. /**
  86. * 订单流转状态:待发货
  87. */
  88. const ORDER_FLOW_NO_SEND = 0;
  89. /**
  90. * 订单流转状态:已取消
  91. */
  92. const ORDER_FLOW_CANCEL = 1;
  93. /**
  94. * 订单流转状态:已发货
  95. */
  96. const ORDER_FLOW_SEND = 2;
  97. /**
  98. * 订单流转状态:已完成
  99. */
  100. const ORDER_FLOW_CONFIRM = 3;
  101. public $valid_order_flow = [
  102. self::ORDER_FLOW_DEFAULT,
  103. self::ORDER_FLOW_NO_SEND,
  104. self::ORDER_FLOW_SEND,
  105. self::ORDER_FLOW_CANCEL,
  106. self::ORDER_FLOW_CONFIRM
  107. ];
  108. /**
  109. * 申请取消订单: 默认
  110. */
  111. const ORDER_APPLY_DELETE_DEFAULT = 0;
  112. /**
  113. * 申请取消订单: 申请中
  114. */
  115. const ORDER_APPLY_DELETE = 1;
  116. /**
  117. * 订单来源 公众号或网站
  118. */
  119. const ORDER_SOURCE_WEB = 1;
  120. /**
  121. * 订单来源 app
  122. */
  123. const ORDER_SOURCE_APP = 2;
  124. /**
  125. * 订单来源 小程序
  126. */
  127. const ORDER_SOURCE_MINI = 3;
  128. /**
  129. * 用户取消类型
  130. */
  131. const CANCEL_USER_TYPE = 0;
  132. /**
  133. * 后台取消类型
  134. */
  135. const CANCEL_BACK_TYPE = 1;
  136. /**
  137. * 是否取消(手动):已取消
  138. */
  139. const IS_DELETE_TRUE = 1;
  140. /**
  141. * 是否取消(手动):未取消
  142. */
  143. const IS_DELETE_FALSE = 0;
  144. /**
  145. * 是否支付:已支付
  146. */
  147. const IS_PAY_TRUE = 1;
  148. /**
  149. * 是否支付:未支付
  150. */
  151. const IS_PAY_FALSE = 0;
  152. /**
  153. * 支付方式:未支付
  154. */
  155. const PAY_TYPE_UNPAID = 0;
  156. /**
  157. * 支付方式:微信支付
  158. */
  159. const PAY_TYPE_WECHAT = 1;
  160. /**
  161. * 支付方式:货到付款
  162. */
  163. const PAY_TYPE_COD = 2;
  164. /**
  165. * 支付方式:余额支付
  166. */
  167. const PAY_TYPE_BALANCE_PAID = 3;
  168. /**
  169. * 订单类型:商城订单
  170. */
  171. const ORDER_TYPE_STORE = 0;
  172. /**
  173. * 订单类型:当面付订单
  174. */
  175. const ORDER_TYPE_POND = 1;
  176. /**
  177. * 订单是否显示:显示
  178. */
  179. const IS_SHOW_TRUE = 1;
  180. /**
  181. * 订单是否显示:不显示
  182. */
  183. const IS_SHOW_FALSE = 0;
  184. /**
  185. * 是否过售后时间:是
  186. */
  187. const IS_SALE_TRUE = 1;
  188. /**
  189. * 是否过售后时间:否
  190. */
  191. const IS_SALE_FALSE = 0;
  192. /**
  193. * 自提订单
  194. */
  195. const IS_OFFLINE_TRUE = 1;
  196. const IS_OFFLINE_FALSE = 0;
  197. /**
  198. * 类型
  199. */
  200. // const SEND_TYPE_DADA = 1;
  201. // const SEND_TYPE_UU = 2;
  202. // const SEND_TYPE_PEISONG = 3;
  203. /**
  204. * 同城配送
  205. */
  206. const IS_SAME_CITY_NO = 0; //否
  207. const IS_SAME_CITY_YES = 1; //是
  208. /**
  209. * 是否是组合支付:是
  210. */
  211. const IS_COMBINE_PAY = 1;
  212. /**
  213. * 是否是组合支付:否
  214. */
  215. const NOT_COMBINE_PAY = 0;
  216. /**
  217. * @inheritdoc
  218. */
  219. public static function tableName()
  220. {
  221. return '{{%adopt_cost_order}}';
  222. }
  223. /**
  224. * @inheritdoc
  225. */
  226. public function rules()
  227. {
  228. return [
  229. [['store_id', 'user_id', 'order_id', 'order_no', ], 'required'],
  230. [['store_id', 'user_id', 'is_pay', 'pay_type', 'pay_time', 'send_time',
  231. 'confirm_time', 'apply_delete', 'created_at', 'updated_at', 'is_delete',
  232. 'is_offline', 'clerk_id', 'shop_id', 'user_coupon_id', 'give_integral',
  233. 'is_sale', 'mch_id', 'is_transfer', 'is_show',
  234. 'order_origin', 'trade_status', 'is_platform', 'is_combine_pay', 'order_type',
  235. 'is_delivery', 'md_id', 'is_trans', 'province_id', 'city_id', 'district_id', 'pay_user_id', ], 'integer'],
  236. [['total_price', 'pay_price', 'express_price',
  237. 'coupon_sub_price', 'before_update_price', 'discount', 'express_price_1',
  238. 'before_update_express', 'combine_money', 'weight'], 'number'],
  239. [['address_data', 'content', 'offline_qrcode', 'integral', 'words', 'seller_comments', 'cost_detail'], 'string'],
  240. [['order_no', 'name', 'mobile', 'express', 'express_no', 'version', 'alipay_trade_no'], 'string', 'max' => 255],
  241. [['address', 'remark'], 'string', 'max' => 1000],
  242. ];
  243. }
  244. /**
  245. * @inheritdoc
  246. */
  247. public function attributeLabels()
  248. {
  249. return [
  250. 'id' => 'ID',
  251. 'store_id' => 'Store ID',
  252. 'user_id' => '用户id',
  253. 'order_id' => '关联认养订单id',
  254. 'order_no' => '订单号',
  255. 'total_price' => '订单总费用(包含运费)',
  256. 'pay_price' => '实际支付总费用(含运费)',
  257. 'express_price' => '运费',
  258. 'name' => '收货人姓名',
  259. 'mobile' => '收货人手机',
  260. 'address' => '收货地址',
  261. 'remark' => '订单备注',
  262. 'is_pay' => '支付状态:0=未支付,1=已支付',
  263. 'pay_type' => '支付方式:1=微信支付',
  264. 'pay_time' => '支付时间',
  265. 'send_time' => '发货时间',
  266. 'express' => '物流公司',
  267. 'express_no' => 'Express No',
  268. 'confirm_time' => '确认收货时间',
  269. 'is_comment' => '是否已评价:0=未评价,1=已评价',
  270. 'apply_delete' => '是否申请取消订单:0=否,1=申请取消订单',
  271. 'created_at' => 'Addtime',
  272. 'is_delete' => 'Is Delete',
  273. 'coupon_sub_price' => '优惠券抵消金额',
  274. 'content' => 'Content',
  275. 'is_offline' => '是否到店自提 0--否 1--是',
  276. 'clerk_id' => '核销员user_id',
  277. 'address_data' => '收货地址信息,json格式',
  278. 'offline_qrcode' => '核销码',
  279. 'before_update_price' => '修改前的价格',
  280. 'shop_id' => '自提自提点ID',
  281. 'discount' => '会员折扣',
  282. 'user_coupon_id' => '使用的优惠券ID',
  283. 'integral' => '积分使用',
  284. 'give_integral' => '是否发放积分【1=> 已发放 , 0=> 未发放】',
  285. 'is_sale' => '是否超过售后时间',
  286. 'words' => '商家留言',
  287. 'version' => '版本',
  288. 'express_price_1' => '减免的运费',
  289. 'mch_id' => '入驻商户id',
  290. 'seller_comments' => '商家备注',
  291. 'before_update_express' => '价格修改前的运费',
  292. 'is_transfer' => '是否已转入商户账户:0=否,1=是',
  293. 'order_type' => '0:采摘订单,1:保管订单',
  294. 'is_show' => '是否显示 0--不显示 1--显示(软删除用)',
  295. 'order_origin' => '订单来源 1:公众号或者网站 2:app 3:小程序',
  296. 'trade_status' => '订单状态,-1:默认,0:待发货,1:已取消,2:已发货,3:已确认',
  297. 'weight' => '提货重量',
  298. 'cost_detail' => '费用明细',
  299. ];
  300. }
  301. public function afterSave($insert, $changedAttributes)
  302. {
  303. parent::afterSave($insert, $changedAttributes);
  304. if($insert){
  305. (new \app\utils\OrderUtil())->adoptCostOrderCancel($this);
  306. }
  307. if(isset($changedAttributes['trade_status']) && $this->trade_status == AdoptCostOrder::ORDER_FLOW_SEND){
  308. (new \app\utils\OrderUtil())->adoptCostOrderConfirm($this);
  309. }
  310. }
  311. }