Browse Source

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

胡轶钦 6 years ago
parent
commit
e5f740772d
6 changed files with 13 additions and 17 deletions
  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 View File

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

+ 2
- 2
conf/db.conf View File

@@ -5,8 +5,8 @@ db_type      = mysql
5 5
 con_protocol = tcp
6 6
 
7 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 10
 # db_addr      = rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com
11 11
 
12 12
 ; 端口

+ 1
- 1
conf/wechat.conf View File

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

+ 3
- 8
service/events/giveCoupon.go View File

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

+ 3
- 3
utils/event.go View File

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

+ 3
- 2
utils/log.go View File

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