| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <?php
- namespace app\models;
- use yii\behaviors\TimestampBehavior;
- use yii\db\ActiveRecord;
- /**
- * Class StoreSync
- * @package app\modules\common\models
- *
- * @property integer $id
- * @property integer $from_id
- * @property integer $to_id
- * @property integer $from_store_id
- * @property integer $to_store_id
- * @property string $type
- * @property integer $created_at
- * @property integer $updated_at
- */
- class StoreSyncExtLog extends ActiveRecord
- {
- const TYPE_POSTAGE_RULES ='delivery_rules';//配送规则
- const TYPE_PRODUCT ='product';//商品
- const TYPE_PRODUCT_ATTR_GROUP ='product_attr_group';//商品规格名
- const TYPE_PRODUCT_ATTR ='product_attr';//商品规格
- const TYPE_PRODUCT_CAT ='product_cat';
- const TYPE_PRODUCT_GOODS_CAT ='product_goods_cat';
- const TYPE_PRODUCT_GOODS_PIC ='product_goods_pic';
- const TYPE_DIY ='diy';
- const TYPE_ACTIVITY_CUT_PRICE ='activityCutPrice';
- const TYPE_ACTIVITY_CUT_PRICE_GOODS ='activity_cut_price_goods';
- const TYPE_ACTIVITY_CUT_PRICE_CAT ='activity_cut_price_cat';
- const TYPE_PT ='pintuan';
- const TYPE_PT_GOODS ='pintuan_goods';
- const TYPE_PT_GOODS_CAT ='pintuan_goods_cat';
- const TYPE_SECKILL ='seckill';
- const TYPE_SECKILL_GOODS ='seckill_goods';
- const TYPE_SHARE_CONFIG ='shareConfig';
- const TYPE_SHARE_HOLDER_CONFIG ='shareHolderConfig';
- const TYPE_VIDEO_GOODS ='videoGoods';
- const TYPE_VIDEO_GOODS_CAT ='video_Goods_Cat';
- const TYPE_INTEGRAL_STORE ='integralStore';
- const TYPE_INTEGRAL_STORE_CAT = 'integral_store_cat';
- const TYPE_WORKER_CONFIG_GOODS ='workerConfig';
- const TYPE_WORKER_CONFIG_CAT ='worker_config_cat';
- const TYPE_WORKER_CONFIG_GOODS_CAT ='worker_config_goods_cat';
- const TYPE_WORKER_CONFIG_LEVEL ='worker_config_level';
- const TYPE_BOOKING_GOODS = 'bookingGoods';
- const TYPE_BOOKING_GOODS_CAT = 'bookingGoodsCat';
- const TYPE_ARTICLE = 'article';
- const TYPE_TOPIC = 'topic';
- const TYPE_TOPIC_TYPE = 'topic_type';
- const TYPE_ARR = [
- self::TYPE_PRODUCT,
- self::TYPE_PRODUCT_CAT,
- self::TYPE_DIY,
- self::TYPE_ACTIVITY_CUT_PRICE,
- self::TYPE_PT,
- self::TYPE_SECKILL,
- self::TYPE_SHARE_CONFIG,
- self::TYPE_SHARE_HOLDER_CONFIG,
- self::TYPE_VIDEO_GOODS,
- self::TYPE_INTEGRAL_STORE,
- self::TYPE_WORKER_CONFIG_GOODS,
- self::TYPE_BOOKING_GOODS,
- self::TYPE_ARTICLE,
- self::TYPE_TOPIC,
- self::TYPE_POSTAGE_RULES
- ];
- public static function tableName()
- {
- return '{{%store_sync_ext_log}}';
- }
- public function behaviors()
- {
- return [
- [
- // 自动更新创建和更新时间
- 'class' => TimestampBehavior::class,
- 'value' => time()
- ]
- ];
- }
- public function rules()
- {
- return [
- [['id', 'from_id', 'to_id', 'from_store_id', 'to_store_id'], 'integer'],
- [['type'], 'string'],
- [['create_at', 'update_at'], 'safe'],
- ];
- }
- public function attributeLabels()
- {
- return [
- 'id' => '',
- 'from_id' => '原店铺内容id',
- 'to_id' => '新店铺内容id',
- 'from_store_id' => '原店铺id',
- 'to_store_id' => '新店铺id',
- 'type' => '类型 代码中给示例值',
- 'created_at' => '',
- 'updated_at' => ''
- ];
- }
- public static function handleData($from_store_id, $to_store_id, $from_id, $to_id, $type = self::TYPE_PRODUCT) {
- $storeSyncExtLog = self::findOne([
- 'from_store_id' => $from_store_id,
- 'to_store_id' => $to_store_id,
- 'from_id' => $from_id,
- 'type' => $type
- ]) ?: new self();
- $storeSyncExtLog->from_id = $from_id;
- $storeSyncExtLog->type = $type;
- $storeSyncExtLog->to_id = $to_id;
- $storeSyncExtLog->from_store_id = $from_store_id;
- $storeSyncExtLog->to_store_id = $to_store_id;
- if (!$storeSyncExtLog->save()) {
- //debug_log(['storeSyncExtLog' => $storeSyncExtLog->errors], 'goods_job.log');
- };
- }
- }
|