StoreCommonSyncLogs.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace addons\Store\common\models;
  3. use common\models\base\BaseActiveRecord;
  4. use Yii;
  5. /**
  6. * This is the model class for table "qimall_addons_store_common_sync_logs".
  7. *
  8. * @property int $id
  9. * @property string $type 类型
  10. * @property int $self_store_id 自身门店ID
  11. * @property int $source_store_id 源门店ID
  12. * @property int $type_id 自身门店的类型id
  13. * @property int $source_type_id 源门店的的类型id
  14. * @property int $created_at
  15. * @property int $updated_at
  16. */
  17. class StoreCommonSyncLogs extends BaseActiveRecord
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public static function tableName()
  23. {
  24. return '{{%addons_store_common_sync_logs}}';
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function rules()
  30. {
  31. return [
  32. [['mall_id', 'self_store_id', 'source_store_id', 'type_id', 'source_type_id', 'created_at', 'updated_at'], 'integer'],
  33. [['type'], 'string', 'max' => 255],
  34. ];
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function attributeLabels()
  40. {
  41. return [
  42. 'id' => 'ID',
  43. 'type' => '类型',
  44. 'mall_id' => '商城ID',
  45. 'self_store_id' => '自身门店ID',
  46. 'source_store_id' => '源门店ID',
  47. 'type_id' => '自身门店的类型id',
  48. 'source_type_id' => '源门店的的类型id',
  49. 'created_at' => 'Created At',
  50. 'updated_at' => 'Updated At',
  51. ];
  52. }
  53. public static function getTypeIds($self_store_id, $source_store_id, $type, $source_type_id)
  54. {
  55. $goods_common_rule_sync_logs_list = self::lists([
  56. 'where' => [
  57. ['self_store_id' => $self_store_id],
  58. ['type' => $type],
  59. ['source_store_id' => $source_store_id],
  60. ['source_type_id' => $source_type_id]
  61. ],
  62. ]);
  63. return array_column($goods_common_rule_sync_logs_list, 'source_type_id');
  64. }
  65. public static function add($self_store_id, $source_store_id, $source_type_id, $type, $type_id, $mall_id)
  66. {
  67. $obj = new self();
  68. $obj->mall_id = $mall_id;
  69. $obj->self_store_id = $self_store_id;
  70. $obj->source_store_id = $source_store_id;
  71. $obj->source_type_id = $source_type_id;
  72. $obj->type = $type;
  73. $obj->type_id = $type_id;
  74. $obj->save();
  75. }
  76. }