BaseOrderForm.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. namespace addons\Happiness\common\logic\order;
  3. use common\enums\PreviewTypeEnum;
  4. use common\enums\ShippingTypeEnum;
  5. use common\helpers\ArrayHelper;
  6. use common\models\order\Order;
  7. use Yii;
  8. use yii\base\Model;
  9. /**
  10. * 订单预览表单逻辑层
  11. * @Author bing
  12. * @DateTime 2021-09-22 18:16:58
  13. * @copyright: Copyright (c) 2020 广东七件事集团
  14. */
  15. class BaseOrderForm extends Model
  16. {
  17. public $mall_id;
  18. public $user_id;
  19. public $user;
  20. public $data; //{"sku_id":"4","num":1}
  21. public $type; //buy_now立即购买 cart购物车
  22. public $order_goods = []; //生成的订单产品
  23. public $default_goods = [];
  24. public $group_order_goods = []; //生成的订单产品组别
  25. public $sku = []; //sku数据
  26. public $address_id; // 收货地址
  27. public $name; // 收货人
  28. public $mobile; // 收货人的手机号码
  29. public $province; // 收货人所在省
  30. public $city; // 收货人所在城市
  31. public $area; // 收货人所在街道
  32. public $town; // 收件人所在乡镇
  33. public $community; // 收件人所在小区
  34. public $region_name; //'收货地区名称(省市区[乡/镇])'
  35. public $address; // 详细地址
  36. public $shipping_type; // 物流类型
  37. public $marketing; // 营销减免
  38. public $total_pay_money; // 营销减免
  39. public $pay_type; // 支付方式
  40. public $transaction; // 支付方式
  41. public $remark; // 用户订单备注
  42. public $action; // preview:订单预览;create:生成订单
  43. public $is_address; // 是否需要收货地址
  44. public $marketing_type; // 营销活动类型
  45. public $is_virtual;//是否虚拟商品
  46. public $is_sign_agreement;//是否需要签署协议
  47. public $is_force_free_shipping = false;//是否强制免运费
  48. public $process_extra_data = []; // 执行中的扩展数据
  49. public $total_pay_money_not_coupon; // 优惠券前价格
  50. public $store_info = [];
  51. public $store_id;
  52. public $share_user_id; //分享的用户ID
  53. /**
  54. * @return array
  55. */
  56. public function rules()
  57. {
  58. return [
  59. [['data', 'type'], 'required'],
  60. [
  61. [
  62. 'mall_id',
  63. 'coupon_id',
  64. 'company_id',
  65. 'address_id',
  66. 'pickup_id',
  67. 'invoice_id',
  68. 'shipping_type',
  69. 'buyer_self_lifting',
  70. 'pickup_point_freight',
  71. 'pickup_point_fee',
  72. 'pickup_point_is_open',
  73. 'marketing_id'
  74. ],
  75. 'integer',
  76. ],
  77. [['invoice_content', 'receiver_name', 'receiver_mobile', 'promo_code', 'marketing_type', 'extra_info', 'remark', 'action'], 'string'],
  78. [['coupon_money', 'use_score', 'shipping_money'], 'number'],
  79. ['type', 'in', 'range' => PreviewTypeEnum::getKeys()],
  80. ['shipping_type', 'in', 'range' => ShippingTypeEnum::getKeys()],
  81. [['company_id'], 'integer', 'min' => 0],
  82. [['pay_type', 's_address'], 'integer', 'min' => 0],
  83. [['combination_num', 'combination_id'], 'integer', 'min' => 1],
  84. [['shipping_type'], 'required', 'on' => ['create']],
  85. [['transaction'], 'safe'],
  86. ];
  87. }
  88. /**
  89. * @return array
  90. */
  91. public function attributeLabels()
  92. {
  93. return ArrayHelper::merge(parent::attributeLabels(), [
  94. 'mall_id' => '商城ID',
  95. 'use_score' => '抵现积分',
  96. 'max_use_score' => '最大可使用积分',
  97. 'address_id' => '收货地址',
  98. 'address' => '收货地址',
  99. 'is_logistics' => '运费模板可选',
  100. 'pickup_id' => '自提点',
  101. 'buyer_self_lifting' => '自提开启',
  102. 'pickup_point_is_open' => '自提运费开启',
  103. 'pickup_point_fee' => '自提运费',
  104. 'pickup_point_freight' => '自提满X包邮',
  105. 'is_full_mail' => '包邮',
  106. 'invoice_id' => '发票',
  107. 'orderProducts' => '生成的订单产品',
  108. 'defaultProducts' => '默认的系统产品',
  109. 'sku' => 'sku数据',
  110. 'member' => '用户',
  111. 'data' => '数据',
  112. 'type' => '数据类型',
  113. 'coupon' => '优惠券',
  114. 'marketing_id' => '营销ID',
  115. 'marketing_type' => '营销类型',
  116. 'pay_type' => '支付方式',
  117. 'transaction' => '流水',
  118. 'share_user_id' => '分享的用户ID'
  119. ]);
  120. }
  121. /**
  122. * 获取用户默认逻辑模型
  123. * @Author bing
  124. * @DateTime 2021-09-22 19:48:46
  125. * @copyright: Copyright (c) 2020 广东七件事集团
  126. * @param $mall_id
  127. * @param $user_id
  128. * @return object
  129. */
  130. public function getDefaultForm($mall_id, $user_id)
  131. {
  132. $model = new self();
  133. $model->mall_id = $mall_id;
  134. $model->user_id = $user_id;
  135. return $model;
  136. }
  137. public function addAttribute($name)
  138. {
  139. $attributes = parent::attributes();
  140. $attributes[] = $name;
  141. return $this;
  142. }
  143. }