Pārlūkot izejas kodu

Merge branch 'dev' of http://git.ycjcjy.com/SpaceOfCheng/services into dev

胡轶钦 6 gadus atpakaļ
vecāks
revīzija
e5f740772d
6 mainītis faili ar 13 papildinājumiem un 17 dzēšanām
  1. 1
    1
      conf/app.conf
  2. 2
    2
      conf/db.conf
  3. 1
    1
      conf/wechat.conf
  4. 3
    8
      service/events/giveCoupon.go
  5. 3
    3
      utils/event.go
  6. 3
    2
      utils/log.go

+ 1
- 1
conf/app.conf Parādīt failu

1
 appname = services
1
 appname = services
2
 httpport = 8080
2
 httpport = 8080
3
-runmode = dev
3
+runmode = prod
4
 autorender = false
4
 autorender = false
5
 copyrequestbody = true
5
 copyrequestbody = true
6
 EnableDocs = true
6
 EnableDocs = true

+ 2
- 2
conf/db.conf Parādīt failu

5
 con_protocol = tcp
5
 con_protocol = tcp
6
 
6
 
7
 ; 数据库地址,可以使用IP
7
 ; 数据库地址,可以使用IP
8
-# db_addr      = 192.168.0.122
9
-db_addr      = localhost
8
+db_addr      = 192.168.0.122
9
+# db_addr      = localhost
10
 # db_addr      = rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com
10
 # db_addr      = rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com
11
 
11
 
12
 ; 端口
12
 ; 端口

+ 1
- 1
conf/wechat.conf Parādīt failu

1
-messageTplID = EB1Bto8JmW-vC-A0NTe8NtxgMFm6s86l3g2Bc-1OP6U
1
+messageTplID = EB1Bto8JmW-vC-A0NTe8NtxgMFm6s86l3g2Bc-1OP6U

+ 3
- 8
service/events/giveCoupon.go Parādīt failu

16
 var giveCoupon = func(e tinyevent.Event) error {
16
 var giveCoupon = func(e tinyevent.Event) error {
17
 	utils.LogInfo("开始卡券赠送操作...")
17
 	utils.LogInfo("开始卡券赠送操作...")
18
 
18
 
19
-	hasDBError := false
20
 	ctx := NewContext()
19
 	ctx := NewContext()
21
-	defer DestroyContext(ctx, hasDBError)
20
+	defer DestroyContext(ctx, false)
22
 
21
 
23
 	if e.Payload == nil {
22
 	if e.Payload == nil {
24
-		hasDBError = true
25
 		utils.LogError("注册送券失败, 没有用户信息")
23
 		utils.LogError("注册送券失败, 没有用户信息")
26
 		return errors.New("注册送券失败, 没有用户信息")
24
 		return errors.New("注册送券失败, 没有用户信息")
27
 	}
25
 	}
47
 
45
 
48
 	var acts []model.SysActivityAction
46
 	var acts []model.SysActivityAction
49
 	if err := models.DBEngine.SQL(query, orgID, caseID, models.STATUS_NORMAL, e.Name).Find(&acts); err != nil {
47
 	if err := models.DBEngine.SQL(query, orgID, caseID, models.STATUS_NORMAL, e.Name).Find(&acts); err != nil {
50
-		hasDBError = true
51
 		utils.LogError("检查营销活动失败: " + err.Error())
48
 		utils.LogError("检查营销活动失败: " + err.Error())
52
 		return errors.New("检查营销活动失败")
49
 		return errors.New("检查营销活动失败")
53
 	}
50
 	}
76
 			cp, err := cpServ.GetCouponByID(cpID.(string))
73
 			cp, err := cpServ.GetCouponByID(cpID.(string))
77
 			if err != nil {
74
 			if err != nil {
78
 				utils.LogError("获取优惠券失败: " + err.Error())
75
 				utils.LogError("获取优惠券失败: " + err.Error())
79
-				hasDBError = true
80
-				return errors.New("校验优惠券失败")
76
+				continue
81
 			}
77
 			}
82
 
78
 
83
 			if err := cpServ.GiveCouponTo(&fromUser, &cust, cp, models.RECEIVEING_TYPE_EVENT); err != nil {
79
 			if err := cpServ.GiveCouponTo(&fromUser, &cust, cp, models.RECEIVEING_TYPE_EVENT); err != nil {
84
-				hasDBError = true
85
 				utils.LogError("送券失败: " + err.Error())
80
 				utils.LogError("送券失败: " + err.Error())
86
-				return err
81
+				continue
87
 			}
82
 			}
88
 		default:
83
 		default:
89
 			utils.LogError("暂不支持的赠送类型")
84
 			utils.LogError("暂不支持的赠送类型")

+ 3
- 3
utils/event.go Parādīt failu

1
 package utils
1
 package utils
2
 
2
 
3
-import "github.com/zjxpcyc/tinyevent"
3
+import (
4
+	"github.com/zjxpcyc/tinyevent"
5
+)
4
 
6
 
5
 // EventEngine Event Engine
7
 // EventEngine Event Engine
6
 type EventEngine struct {
8
 type EventEngine struct {
53
 
55
 
54
 // EmitEvent 执行事件
56
 // EmitEvent 执行事件
55
 func (t EventEngine) EmitEvent(evt string, payload interface{}) {
57
 func (t EventEngine) EmitEvent(evt string, payload interface{}) {
56
-	LogInfo("触发事件: "+evt, payload)
57
-
58
 	e := tinyevent.Event{
58
 	e := tinyevent.Event{
59
 		Name:    evt,
59
 		Name:    evt,
60
 		Payload: payload,
60
 		Payload: payload,

+ 3
- 2
utils/log.go Parādīt failu

57
 	log := instances["common"]
57
 	log := instances["common"]
58
 
58
 
59
 	preMsg := ""
59
 	preMsg := ""
60
-	_, file, line, ok := runtime.Caller(0)
60
+	_, file, line, ok := runtime.Caller(1)
61
 	if ok {
61
 	if ok {
62
 		preMsg = fmt.Sprintf("file: %s    line=%d : ", file, line)
62
 		preMsg = fmt.Sprintf("file: %s    line=%d : ", file, line)
63
 	}
63
 	}
86
 	log := instances["common"]
86
 	log := instances["common"]
87
 
87
 
88
 	preMsg := ""
88
 	preMsg := ""
89
-	_, file, line, ok := runtime.Caller(0)
89
+	_, file, line, ok := runtime.Caller(1)
90
 	if ok {
90
 	if ok {
91
 		preMsg = fmt.Sprintf("file: %s    line=%d : ", file, line)
91
 		preMsg = fmt.Sprintf("file: %s    line=%d : ", file, line)
92
 	}
92
 	}
97
 // GetDefaultLogger 获取默认 logger
97
 // GetDefaultLogger 获取默认 logger
98
 func GetDefaultLogger() *logs.BeeLogger {
98
 func GetDefaultLogger() *logs.BeeLogger {
99
 	log := instances["common"]
99
 	log := instances["common"]
100
+	log.SetLogFuncCallDepth(4)
100
 	return log
101
 	return log
101
 }
102
 }
102
 
103