|
|
@@ -35,7 +35,7 @@ func (s *SubscribeOpenService) createSubscribe(deviceId, openId, module string)
|
|
|
return mgm.Coll(sub).Create(sub)
|
|
|
}
|
|
|
|
|
|
-func (this *SubscribeOpenService) updateSubscribe(deviceId string, module string) error {
|
|
|
+func (this *SubscribeOpenService) updateSubscribe(deviceId string, openId string, module string) error {
|
|
|
now := util.GetNowSecond()
|
|
|
|
|
|
filter := bson.M{"device_id": deviceId}
|
|
|
@@ -43,6 +43,7 @@ func (this *SubscribeOpenService) updateSubscribe(deviceId string, module string
|
|
|
update := bson.M{
|
|
|
"$set": bson.M{
|
|
|
"device_id": deviceId,
|
|
|
+ "open_id": openId,
|
|
|
"modules." + module: bson.M{
|
|
|
"enabled": true,
|
|
|
"open_at": now,
|
|
|
@@ -60,6 +61,8 @@ func (this *SubscribeOpenService) updateSubscribe(deviceId string, module string
|
|
|
}
|
|
|
|
|
|
func (this *SubscribeOpenService) Open() error {
|
|
|
+ logger.Info("user sign subscribe device_id: %s open_id: %s, module: %s", this.DeviceId, this.OpenId, this.Module)
|
|
|
+
|
|
|
subscribeOne := new(subscribe.Subscribe)
|
|
|
err := mgm.Coll(&subscribe.Subscribe{}).First(bson.M{"device_id": this.DeviceId}, subscribeOne)
|
|
|
if err != nil {
|
|
|
@@ -72,7 +75,7 @@ func (this *SubscribeOpenService) Open() error {
|
|
|
// 2️⃣ 其他错误
|
|
|
return err
|
|
|
}
|
|
|
- return this.updateSubscribe(this.DeviceId, this.Module)
|
|
|
+ return this.updateSubscribe(this.DeviceId, this.OpenId, this.Module)
|
|
|
}
|
|
|
|
|
|
type SubscribeCloseService struct {
|