| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace addons\Store\common\models;
- use common\enums\StatusEnum;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_store_effect_order".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $store_id 门店id
- * @property int $user_id 订单id,store_order表的user_id
- * @property int $store_user_id 门店用户id
- * @property int $order_id 订单id,store_order表的id
- * @property int $status 状态,-1删除,0禁用,1正常
- * @property int $created_at
- * @property int $updated_at
- */
- class StoreEffectOrder extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'qimall_addons_store_effect_order';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'store_id', 'user_id', 'store_user_id', 'order_id', 'status', 'created_at', 'updated_at'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => 'Mall ID',
- 'store_id' => '门店id',
- 'user_id' => '订单id,store_order表的user_id',
- 'store_user_id' => '门店用户id',
- 'order_id' => '订单id,store_order表的id',
- 'status' => '状态,-1删除,0禁用,1正常',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- public static function batchAdd($order_ids, $store_id, $store_user_id, $user_id, $mall_id)
- {
- if (!is_array($order_ids)) return false;
- $data = [];
- foreach ($order_ids as $order_id) {
- $data[] = [
- 'mall_id' => $mall_id,
- 'store_id' => $store_id,
- 'user_id' => $user_id,
- 'store_user_id' => $store_user_id,
- 'order_id' => $order_id,
- 'status' => StatusEnum::ENABLED,
- 'created_at' => time(),
- 'updated_at' => time(),
- ];
- }
- if ($data) {
- $res = \Yii::$app->db->createCommand()->batchInsert(self::tableName(), array_keys($data[0]), $data)->execute();
- if ($res === false) {
- \Yii::error('门店入驻限制:批量添加StoreEffectOrder失败' . self::$static_error);
- }
- return true;
- }
- return false;
- }
- }
|