StoreEffectOrder.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace addons\Store\common\models;
  3. use common\enums\StatusEnum;
  4. use Yii;
  5. /**
  6. * This is the model class for table "qimall_addons_store_effect_order".
  7. *
  8. * @property int $id
  9. * @property int $mall_id
  10. * @property int $store_id 门店id
  11. * @property int $user_id 订单id,store_order表的user_id
  12. * @property int $store_user_id 门店用户id
  13. * @property int $order_id 订单id,store_order表的id
  14. * @property int $status 状态,-1删除,0禁用,1正常
  15. * @property int $created_at
  16. * @property int $updated_at
  17. */
  18. class StoreEffectOrder extends \common\models\base\BaseActiveRecord
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return 'qimall_addons_store_effect_order';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['mall_id', 'store_id', 'user_id', 'store_user_id', 'order_id', 'status', 'created_at', 'updated_at'], 'integer'],
  34. ];
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function attributeLabels()
  40. {
  41. return [
  42. 'id' => 'ID',
  43. 'mall_id' => 'Mall ID',
  44. 'store_id' => '门店id',
  45. 'user_id' => '订单id,store_order表的user_id',
  46. 'store_user_id' => '门店用户id',
  47. 'order_id' => '订单id,store_order表的id',
  48. 'status' => '状态,-1删除,0禁用,1正常',
  49. 'created_at' => 'Created At',
  50. 'updated_at' => 'Updated At',
  51. ];
  52. }
  53. public static function batchAdd($order_ids, $store_id, $store_user_id, $user_id, $mall_id)
  54. {
  55. if (!is_array($order_ids)) return false;
  56. $data = [];
  57. foreach ($order_ids as $order_id) {
  58. $data[] = [
  59. 'mall_id' => $mall_id,
  60. 'store_id' => $store_id,
  61. 'user_id' => $user_id,
  62. 'store_user_id' => $store_user_id,
  63. 'order_id' => $order_id,
  64. 'status' => StatusEnum::ENABLED,
  65. 'created_at' => time(),
  66. 'updated_at' => time(),
  67. ];
  68. }
  69. if ($data) {
  70. $res = \Yii::$app->db->createCommand()->batchInsert(self::tableName(), array_keys($data[0]), $data)->execute();
  71. if ($res === false) {
  72. \Yii::error('门店入驻限制:批量添加StoreEffectOrder失败' . self::$static_error);
  73. }
  74. return true;
  75. }
  76. return false;
  77. }
  78. }