BaseOrderForm.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. namespace addons\UpgradeGift\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. /**
  51. * @return array
  52. */
  53. public function rules()
  54. {
  55. return [
  56. [['data', 'type'], 'required'],
  57. [
  58. [
  59. 'mall_id',
  60. 'coupon_id',
  61. 'company_id',
  62. 'address_id',
  63. 'pickup_id',
  64. 'invoice_id',
  65. 'shipping_type',
  66. 'buyer_self_lifting',
  67. 'pickup_point_freight',
  68. 'pickup_point_fee',
  69. 'pickup_point_is_open',
  70. 'marketing_id',
  71. ],
  72. 'integer',
  73. ],
  74. [['invoice_content', 'receiver_name', 'receiver_mobile', 'promo_code', 'marketing_type', 'extra_info', 'remark', 'action'], 'string'],
  75. [['coupon_money', 'use_score', 'shipping_money'], 'number'],
  76. ['type', 'in', 'range' => PreviewTypeEnum::getKeys()],
  77. ['shipping_type', 'in', 'range' => ShippingTypeEnum::getKeys()],
  78. [['company_id'], 'integer', 'min' => 0],
  79. [['pay_type', 's_address'], 'integer', 'min' => 0],
  80. [['combination_num', 'combination_id'], 'integer', 'min' => 1],
  81. [['shipping_type'], 'required', 'on' => ['create']],
  82. [['transaction'], 'safe'],
  83. ];
  84. }
  85. /**
  86. * @return array
  87. */
  88. public function attributeLabels()
  89. {
  90. return ArrayHelper::merge(parent::attributeLabels(), [
  91. 'mall_id' => '商城ID',
  92. 'use_score' => '抵现积分',
  93. 'max_use_score' => '最大可使用积分',
  94. 'address_id' => '收货地址',
  95. 'address' => '收货地址',
  96. 'is_logistics' => '运费模板可选',
  97. 'pickup_id' => '自提点',
  98. 'buyer_self_lifting' => '自提开启',
  99. 'pickup_point_is_open' => '自提运费开启',
  100. 'pickup_point_fee' => '自提运费',
  101. 'pickup_point_freight' => '自提满X包邮',
  102. 'is_full_mail' => '包邮',
  103. 'invoice_id' => '发票',
  104. 'orderProducts' => '生成的订单产品',
  105. 'defaultProducts' => '默认的系统产品',
  106. 'sku' => 'sku数据',
  107. 'member' => '用户',
  108. 'data' => '数据',
  109. 'type' => '数据类型',
  110. 'coupon' => '优惠券',
  111. 'marketing_id' => '营销ID',
  112. 'marketing_type' => '营销类型',
  113. 'pay_type' => '支付方式',
  114. 'transaction' => '流水',
  115. ]);
  116. }
  117. /**
  118. * 获取用户默认逻辑模型
  119. * @Author bing
  120. * @DateTime 2021-09-22 19:48:46
  121. * @copyright: Copyright (c) 2020 广东七件事集团
  122. * @param $mall_id
  123. * @param $user_id
  124. * @return object
  125. */
  126. public function getDefaultForm($mall_id, $user_id)
  127. {
  128. $model = new self();
  129. $model->mall_id = $mall_id;
  130. $model->user_id = $user_id;
  131. return $model;
  132. }
  133. public function addAttribute($name)
  134. {
  135. $attributes = parent::attributes();
  136. $attributes[] = $name;
  137. return $this;
  138. }
  139. }