Browse Source

debug

master v0.7.7
lijianbin 3 years ago
parent
commit
a196dd9e1b
2 changed files with 53 additions and 51 deletions
  1. +16
    -18
      account.client.go
  2. +37
    -33
      account.client_test.go

+ 16
- 18
account.client.go View File

@ -49,15 +49,10 @@ type GetCouponReq struct {
UserId string UserId string
CouponId string CouponId string
ExpireTime string ExpireTime string
}
type GetUpdateCouponReq struct {
Req
UserId string
CouponId string
OrderSn string
Remark string
IsUse string
OrderSn string
Remark string
IsUse string
Usertime string
} }
/** /**
@ -223,7 +218,7 @@ func AddUserScore(dbname, userId, score string, url ...string) (int64, error) {
* @bin * @bin
*/ */
func UpdateUserScore(dbname, userId, score, used_score string, url ...string) (bool, error) { func UpdateUserScore(dbname, userId, score, used_score string, url ...string) (bool, error) {
if dbname == "" || userId == "" || score == "" || used_score == "" {
if dbname == "" || userId == "" || score == "" {
return false, errors.New("参数错误") return false, errors.New("参数错误")
} }
@ -578,7 +573,7 @@ func AddUserRedEnvelope(dbname, userId, money string, url ...string) (int64, err
* @2021/09/30 * @2021/09/30
* @bin * @bin
*/ */
func UpdateUserRedEnvelope(dbname, userId, money string, url ...string) (bool, error) {
func UpdateUserRedEnvelope(dbname, userId, money, used_money string, url ...string) (bool, error) {
if dbname == "" || userId == "" || money == "" { if dbname == "" || userId == "" || money == "" {
return false, errors.New("参数错误") return false, errors.New("参数错误")
} }
@ -589,10 +584,11 @@ func UpdateUserRedEnvelope(dbname, userId, money string, url ...string) (bool, e
} }
defer conn.Close() defer conn.Close()
data := GetAddReq{}
data := GetUpdateReq{}
data.Dbname = dbname data.Dbname = dbname
data.UserId = userId data.UserId = userId
data.Value = money data.Value = money
data.UsedValue = used_money
req, err := SetReqData(data) req, err := SetReqData(data)
if err != nil { if err != nil {
@ -602,7 +598,7 @@ func UpdateUserRedEnvelope(dbname, userId, money string, url ...string) (bool, e
res := &Response{} res := &Response{}
err = conn.UpdateUserUpgrade(req, res)
err = conn.UpdateUserRedEnvelope(req, res)
if err != nil { if err != nil {
log.Println("userrpc UpdateUserRedEnvelope error:", err) log.Println("userrpc UpdateUserRedEnvelope error:", err)
@ -635,7 +631,7 @@ func UpdateUserRedEnvelope(dbname, userId, money string, url ...string) (bool, e
* @2021/09/30 * @2021/09/30
* @bin * @bin
*/ */
func AddUserRedEnvelopeLog(dbname, UserId, Money, Before, After, Source, SourceId, OrderSn, Target, TargetId, ProductThumb, Memo string, url ...string) (int64, error) {
func AddUserRedEnvelopeLog(dbname, UserId, Money, Before, After, Source, SourceId, OrderSn, Target, TargetId, Memo string, url ...string) (int64, error) {
if dbname == "" || UserId == "" || Money == "" || After == "" { if dbname == "" || UserId == "" || Money == "" || After == "" {
return 0, errors.New("参数错误") return 0, errors.New("参数错误")
} }
@ -657,7 +653,6 @@ func AddUserRedEnvelopeLog(dbname, UserId, Money, Before, After, Source, SourceI
data.OrderSn = OrderSn data.OrderSn = OrderSn
data.Target = Target data.Target = Target
data.TargetId = TargetId data.TargetId = TargetId
data.ProductThumb = ProductThumb
data.Memo = Memo data.Memo = Memo
req, err := SetReqData(data) req, err := SetReqData(data)
@ -701,7 +696,7 @@ func AddUserRedEnvelopeLog(dbname, UserId, Money, Before, After, Source, SourceI
* @2021/09/30 * @2021/09/30
* @bin * @bin
*/ */
func AddUserCoupon(dbname, userId, couponId, expireTime string, url ...string) (int64, error) {
func AddUserCoupon(dbname, userId, couponId, expireTime, orderSn, remark string, url ...string) (int64, error) {
if dbname == "" || userId == "" || couponId == "" { if dbname == "" || userId == "" || couponId == "" {
return 0, errors.New("参数错误") return 0, errors.New("参数错误")
} }
@ -717,6 +712,8 @@ func AddUserCoupon(dbname, userId, couponId, expireTime string, url ...string) (
data.UserId = userId data.UserId = userId
data.CouponId = couponId data.CouponId = couponId
data.ExpireTime = expireTime data.ExpireTime = expireTime
data.OrderSn = orderSn
data.Remark = remark
req, err := SetReqData(data) req, err := SetReqData(data)
if err != nil { if err != nil {
@ -759,7 +756,7 @@ func AddUserCoupon(dbname, userId, couponId, expireTime string, url ...string) (
* @2021/09/30 * @2021/09/30
* @bin * @bin
*/ */
func UpdateUserCoupon(dbname, userId, couponId, remark, orderSn, isUse string, url ...string) (bool, error) {
func UpdateUserCoupon(dbname, userId, couponId, remark, orderSn, isUse, usetime string, url ...string) (bool, error) {
if dbname == "" || userId == "" || couponId == "" { if dbname == "" || userId == "" || couponId == "" {
return false, errors.New("参数错误") return false, errors.New("参数错误")
} }
@ -770,13 +767,14 @@ func UpdateUserCoupon(dbname, userId, couponId, remark, orderSn, isUse string, u
} }
defer conn.Close() defer conn.Close()
data := GetUpdateCouponReq{}
data := GetCouponReq{}
data.Dbname = dbname data.Dbname = dbname
data.UserId = userId data.UserId = userId
data.CouponId = couponId data.CouponId = couponId
data.Remark = remark data.Remark = remark
data.OrderSn = orderSn data.OrderSn = orderSn
data.IsUse = isUse data.IsUse = isUse
data.Usertime = usetime
req, err := SetReqData(data) req, err := SetReqData(data)
if err != nil { if err != nil {


+ 37
- 33
account.client_test.go View File

@ -6,7 +6,7 @@ import (
func Test_GetUserScore(t *testing.T) { func Test_GetUserScore(t *testing.T) {
dbname := "shop_v2"
dbname := "shop_v2_org"
id := "2" id := "2"
ret, err := GetUserScore(dbname, id) ret, err := GetUserScore(dbname, id)
@ -16,7 +16,7 @@ func Test_GetUserScore(t *testing.T) {
func Test_GetUserRedEnvelope(t *testing.T) { func Test_GetUserRedEnvelope(t *testing.T) {
dbname := "shop_v2"
dbname := "shop_v2_org"
id := "2" id := "2"
ret, err := GetUserRedEnvelope(dbname, id) ret, err := GetUserRedEnvelope(dbname, id)
@ -25,7 +25,7 @@ func Test_GetUserRedEnvelope(t *testing.T) {
} }
func Test_AddUserScore(t *testing.T) { func Test_AddUserScore(t *testing.T) {
dbname := "shop_v2"
dbname := "shop_v2_org"
userid := "2" userid := "2"
score := "20" score := "20"
@ -35,10 +35,10 @@ func Test_AddUserScore(t *testing.T) {
} }
func Test_UpdateUserScore(t *testing.T) { func Test_UpdateUserScore(t *testing.T) {
dbname := "shop_v2"
dbname := "shop_v2_org"
userid := "2" userid := "2"
score := "20"
used_score := "10"
score := "400"
used_score := "300"
ret, err := UpdateUserScore(dbname, userid, score, used_score) ret, err := UpdateUserScore(dbname, userid, score, used_score)
t.Log(ret) t.Log(ret)
@ -46,11 +46,11 @@ func Test_UpdateUserScore(t *testing.T) {
} }
func Test_AddUserScoreLog(t *testing.T) { func Test_AddUserScoreLog(t *testing.T) {
dbname := "shop_v2"
dbname := "shop_v2_org"
userid := "2" userid := "2"
score := "20"
before := "10"
after := "30"
score := "100"
before := "500"
after := "400"
Source := "task" Source := "task"
SourceId := "" SourceId := ""
OrderSn := "" OrderSn := ""
@ -65,9 +65,9 @@ func Test_AddUserScoreLog(t *testing.T) {
} }
func Test_AddUserUpgrade(t *testing.T) { func Test_AddUserUpgrade(t *testing.T) {
dbname := "shop_v2"
userid := "2"
upgrade := "20"
dbname := "shop_v2_org"
userid := "5"
upgrade := "100"
ret, err := AddUserUpgrade(dbname, userid, upgrade) ret, err := AddUserUpgrade(dbname, userid, upgrade)
t.Log(ret) t.Log(ret)
@ -75,9 +75,9 @@ func Test_AddUserUpgrade(t *testing.T) {
} }
func Test_UpdateUserUpgrade(t *testing.T) { func Test_UpdateUserUpgrade(t *testing.T) {
dbname := "shop_v2"
userid := "2"
upgrade := "20"
dbname := "shop_v2_org"
userid := "5"
upgrade := "100"
ret, err := UpdateUserUpgrade(dbname, userid, upgrade) ret, err := UpdateUserUpgrade(dbname, userid, upgrade)
t.Log(ret) t.Log(ret)
@ -85,11 +85,11 @@ func Test_UpdateUserUpgrade(t *testing.T) {
} }
func Test_AddUserUpgradeLog(t *testing.T) { func Test_AddUserUpgradeLog(t *testing.T) {
dbname := "shop_v2"
dbname := "shop_v2_org"
userid := "2" userid := "2"
upgrade := "20" upgrade := "20"
before := "10"
after := "30"
before := "11"
after := "31"
Source := "task" Source := "task"
Memo := "" Memo := ""
@ -99,8 +99,8 @@ func Test_AddUserUpgradeLog(t *testing.T) {
} }
func Test_AddUserRedEnvelope(t *testing.T) { func Test_AddUserRedEnvelope(t *testing.T) {
dbname := "shop_v2"
userid := "2"
dbname := "shop_v2_org"
userid := "5"
money := "20" money := "20"
ret, err := AddUserRedEnvelope(dbname, userid, money) ret, err := AddUserRedEnvelope(dbname, userid, money)
@ -109,24 +109,25 @@ func Test_AddUserRedEnvelope(t *testing.T) {
} }
func Test_UpdateUserRedEnvelope(t *testing.T) { func Test_UpdateUserRedEnvelope(t *testing.T) {
dbname := "shop_v2"
dbname := "shop_v2_org"
userid := "2" userid := "2"
money := "20"
money := "40"
used_money := "1"
ret, err := UpdateUserRedEnvelope(dbname, userid, money)
ret, err := UpdateUserRedEnvelope(dbname, userid, money, used_money)
t.Log(ret) t.Log(ret)
t.Log(err) t.Log(err)
} }
func Test_AddUserRedEnvelopeLog(t *testing.T) { func Test_AddUserRedEnvelopeLog(t *testing.T) {
dbname := "shop_v2"
dbname := "shop_v2_org"
userid := "2" userid := "2"
money := "20"
before := "10"
after := "30"
money := "-1"
before := "41"
after := "40"
Source := "task" Source := "task"
SourceId := "" SourceId := ""
OrderSn := ""
OrderSn := "216304042479173922"
Target := "" Target := ""
TargetId := "" TargetId := ""
ProductThumb := "" ProductThumb := ""
@ -138,25 +139,28 @@ func Test_AddUserRedEnvelopeLog(t *testing.T) {
} }
func Test_AddUserCoupon(t *testing.T) { func Test_AddUserCoupon(t *testing.T) {
dbname := "shop_v2"
dbname := "shop_v2_org"
userid := "2" userid := "2"
couponId := "20" couponId := "20"
expired_time := "" expired_time := ""
order_sn := ""
remark := ""
ret, err := AddUserCoupon(dbname, userid, couponId, expired_time)
ret, err := AddUserCoupon(dbname, userid, couponId, expired_time,order_sn,remark)
t.Log(ret) t.Log(ret)
t.Log(err) t.Log(err)
} }
func Test_UpdateUserCoupon(t *testing.T) { func Test_UpdateUserCoupon(t *testing.T) {
dbname := "shop_v2"
dbname := "shop_v2_org"
userid := "2" userid := "2"
couponId := "20" couponId := "20"
remark := "" remark := ""
orderSn := "" orderSn := ""
isUse := "" isUse := ""
usetime := ""
ret, err := UpdateUserCoupon(dbname, userid, couponId, remark, orderSn, isUse)
ret, err := UpdateUserCoupon(dbname, userid, couponId, remark, orderSn, isUse,usetime)
t.Log(ret) t.Log(ret)
t.Log(err) t.Log(err)
} }

Loading…
Cancel
Save