fix:
This commit is contained in:
parent
133ed7db4b
commit
f3a8ac8a55
|
@ -25,11 +25,25 @@ func CooperativeGameCardGoodsStockAdds(c *gin.Context) {
|
||||||
RespJson(c, status.Unauthorized, nil)
|
RespJson(c, status.Unauthorized, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if assistant.XcxRoleId != 2 {
|
||||||
|
logger.Error("not shop manager")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
serialNumbers := ""
|
||||||
cardGoods := &model.GameCardGoods{}
|
cardGoods := &model.GameCardGoods{}
|
||||||
for i, _ := range req.Cards {
|
for i, _ := range req.Cards {
|
||||||
req.Cards[i].CardType = model.GameCardGoodsTypeCommon
|
req.Cards[i].CardType = model.GameCardGoodsTypeCommon
|
||||||
req.Cards[i].ShareProfitType = 1
|
req.Cards[i].ShareProfitType = 1
|
||||||
|
req.Cards[i].Status = model.GameCardGoodsStatusStock
|
||||||
|
req.Cards[i].StoreId = assistant.StoreId
|
||||||
|
serialNumbers += req.Cards[i].SerialNumber + ","
|
||||||
}
|
}
|
||||||
err := cardGoods.Adds(req.Cards)
|
err := cardGoods.Adds(req.Cards)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -38,6 +52,19 @@ func CooperativeGameCardGoodsStockAdds(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operationLog := &model.OperationLog{
|
||||||
|
Uid: assistant.Uid,
|
||||||
|
Description: "游戏卡入库",
|
||||||
|
OperationType: model.OperationTypeGameCardGoodsInStock,
|
||||||
|
CorrelationName: model.LogCorrelationOrderId,
|
||||||
|
StoreId: uint32(assistant.StoreId),
|
||||||
|
StoreName: "",
|
||||||
|
CooperativeName: assistant.CooperativeName,
|
||||||
|
CooperativeBusinessId: assistant.CooperativeBusinessId,
|
||||||
|
Detail: serialNumbers[:len(serialNumbers)-1],
|
||||||
|
}
|
||||||
|
operationLog.AddLog()
|
||||||
|
|
||||||
RespOK(c, nil)
|
RespOK(c, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -49,7 +76,19 @@ func GameCardGoodsStockAnalysis(c *gin.Context) {
|
||||||
RespJson(c, status.BadRequest, nil)
|
RespJson(c, status.BadRequest, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
uc := auth.GetCurrentUser(c)
|
||||||
|
if uc == nil {
|
||||||
|
logger.Error("uc is nil")
|
||||||
|
RespJson(c, status.Unauthorized, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req.StoreId = uint32(assistant.StoreId)
|
||||||
resp, err := req.GameCardStockListAnalysis()
|
resp, err := req.GameCardStockListAnalysis()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("err:", err)
|
logger.Error("err:", err)
|
||||||
|
@ -78,7 +117,11 @@ func CooperativeExportDataGameCardGoodsStock(c *gin.Context) {
|
||||||
RespJson(c, status.NoAuth, nil)
|
RespJson(c, status.NoAuth, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
goodsStock := model.ExportGoodsStock(uint32(assistant.StoreId))
|
goodsStock := model.ExportGoodsStock(uint32(assistant.StoreId))
|
||||||
|
|
||||||
ret := &map[string]interface{}{
|
ret := &map[string]interface{}{
|
||||||
|
@ -107,6 +150,11 @@ func CooperativeCannibalizeTaskCreate(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assistant := model.GetUserByUid(uc.Uid)
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
req.FromStoreId = uint32(assistant.StoreId)
|
req.FromStoreId = uint32(assistant.StoreId)
|
||||||
if req.FromStoreId == 0 || req.ToStoreId == 0 {
|
if req.FromStoreId == 0 || req.ToStoreId == 0 {
|
||||||
RespJson(c, status.BadRequest, nil)
|
RespJson(c, status.BadRequest, nil)
|
||||||
|
@ -141,6 +189,19 @@ func CooperativeCannibalizeTaskImportGoods(c *gin.Context) {
|
||||||
RespJson(c, status.BadRequest, nil)
|
RespJson(c, status.BadRequest, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uc := auth.GetCurrentUser(c)
|
||||||
|
if uc == nil {
|
||||||
|
logger.Error("uc is nil")
|
||||||
|
RespJson(c, status.Unauthorized, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
unImportGoods, err := model.CannibalizeTaskImportGoods(req.CannibalizeStockTaskId, req.SerialNumberList)
|
unImportGoods, err := model.CannibalizeTaskImportGoods(req.CannibalizeStockTaskId, req.SerialNumberList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("err:", err)
|
logger.Error("err:", err)
|
||||||
|
@ -168,6 +229,18 @@ func CooperativeCannibalizeTaskDeliverGoods(c *gin.Context) {
|
||||||
RespJson(c, status.BadRequest, nil)
|
RespJson(c, status.BadRequest, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
uc := auth.GetCurrentUser(c)
|
||||||
|
if uc == nil {
|
||||||
|
logger.Error("uc is nil")
|
||||||
|
RespJson(c, status.Unauthorized, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
err := model.CannibalizeDeliverGoods(req.CannibalizeStockTaskId)
|
err := model.CannibalizeDeliverGoods(req.CannibalizeStockTaskId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("err:", err)
|
logger.Error("err:", err)
|
||||||
|
@ -192,6 +265,18 @@ func CooperativeCannibalizeTaskPutInStorage(c *gin.Context) {
|
||||||
RespJson(c, status.BadRequest, nil)
|
RespJson(c, status.BadRequest, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
uc := auth.GetCurrentUser(c)
|
||||||
|
if uc == nil {
|
||||||
|
logger.Error("uc is nil")
|
||||||
|
RespJson(c, status.Unauthorized, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
err := model.CannibalizePutInStorage(req.CannibalizeStockTaskId)
|
err := model.CannibalizePutInStorage(req.CannibalizeStockTaskId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("err:", err)
|
logger.Error("err:", err)
|
||||||
|
@ -219,6 +304,11 @@ func CooperativeCannibalizeTaskList(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assistant := model.GetUserByUid(uc.Uid)
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
req.StoreId = uint32(assistant.StoreId)
|
req.StoreId = uint32(assistant.StoreId)
|
||||||
if req.StoreId == 0 {
|
if req.StoreId == 0 {
|
||||||
RespJson(c, status.BadRequest, nil)
|
RespJson(c, status.BadRequest, nil)
|
||||||
|
@ -247,7 +337,18 @@ func CooperativeCannibalizeTaskGameCardGoodsList(c *gin.Context) {
|
||||||
RespJson(c, status.BadRequest, nil)
|
RespJson(c, status.BadRequest, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
uc := auth.GetCurrentUser(c)
|
||||||
|
if uc == nil {
|
||||||
|
logger.Error("uc is nil")
|
||||||
|
RespJson(c, status.Unauthorized, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
resp, err := req.GetCannibalizeTaskGameCardGoodsList()
|
resp, err := req.GetCannibalizeTaskGameCardGoodsList()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("err:", err)
|
logger.Error("err:", err)
|
||||||
|
@ -271,6 +372,18 @@ func CooperativeCannibalizeTaskDel(c *gin.Context) {
|
||||||
RespJson(c, status.BadRequest, nil)
|
RespJson(c, status.BadRequest, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
uc := auth.GetCurrentUser(c)
|
||||||
|
if uc == nil {
|
||||||
|
logger.Error("uc is nil")
|
||||||
|
RespJson(c, status.Unauthorized, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
err := model.CannibalizeTaskDel(req.CannibalizeStockTaskId)
|
err := model.CannibalizeTaskDel(req.CannibalizeStockTaskId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("err:", err)
|
logger.Error("err:", err)
|
||||||
|
@ -300,7 +413,12 @@ func CooperativeGameCardGoodsList(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.AssistantUid = uc.Uid
|
req.AssistantUid = uc.Uid
|
||||||
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
resp, err := req.List()
|
resp, err := req.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("list err:", err)
|
logger.Error("list err:", err)
|
||||||
|
@ -338,6 +456,11 @@ func AssistantMemberPromotionList(c *gin.Context) {
|
||||||
RespJson(c, status.NoAuth, nil)
|
RespJson(c, status.NoAuth, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if req.Assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
list, totalPage, err := req.List()
|
list, totalPage, err := req.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("list err:", err)
|
logger.Error("list err:", err)
|
||||||
|
|
|
@ -53,6 +53,12 @@ func CooperativeRentCardOrderInfo(c *gin.Context) {
|
||||||
RespJson(c, status.Unauthorized, nil)
|
RespJson(c, status.Unauthorized, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
order, err := req.Info()
|
order, err := req.Info()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("rent card order err:", err)
|
logger.Error("rent card order err:", err)
|
||||||
|
@ -83,6 +89,11 @@ func CooperativeRentCardOrderDeliver(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
assistant := model.GetUserByUid(uc.Uid)
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
req.OperationUid = uc.Uid
|
req.OperationUid = uc.Uid
|
||||||
req.StoreId = uint32(assistant.StoreId)
|
req.StoreId = uint32(assistant.StoreId)
|
||||||
err, _ := req.Deliver()
|
err, _ := req.Deliver()
|
||||||
|
@ -109,6 +120,12 @@ func CooperativeRentCardOrderRevert(c *gin.Context) {
|
||||||
RespJson(c, status.Unauthorized, nil)
|
RespJson(c, status.Unauthorized, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
req.OperationUid = uc.Uid
|
req.OperationUid = uc.Uid
|
||||||
err := req.Revert()
|
err := req.Revert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -989,6 +989,12 @@ func InviteMemberReportList(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Uid = uc.Uid
|
req.Uid = uc.Uid
|
||||||
|
assistant := model.GetUserByUid(uc.Uid)
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
logger.Error("not assistant")
|
||||||
|
RespJson(c, status.InternalServerError, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
list, totalPage, err := req.List()
|
list, totalPage, err := req.List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("err:", err)
|
logger.Errorf("err:", err)
|
||||||
|
|
|
@ -131,3 +131,70 @@ func getParam(company, num string) (string, error) {
|
||||||
}
|
}
|
||||||
return string(paramMapJson), nil
|
return string(paramMapJson), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *KdClient) subscribePost(kdApi string, params *url.Values, resp interface{}) error {
|
||||||
|
//params.Set("customer", m.Customer)
|
||||||
|
uri := m.BaseURL + kdApi + params.Encode()
|
||||||
|
fmt.Println("uri:", uri)
|
||||||
|
|
||||||
|
res, err := http.Post(uri, "application/x-www-form-urlencoded", nil)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//res.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
data, err := ioutil.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err = json.Unmarshal(data, resp); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type SubscribeExpressStateResp struct {
|
||||||
|
Result bool `json:"result"`
|
||||||
|
ReturnCode string `json:"returnCode"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func SubscribeExpressState(expressCompanyNo, expressNum string) (*SubscribeExpressStateResp, error) {
|
||||||
|
resp := &SubscribeExpressStateResp{}
|
||||||
|
|
||||||
|
paramsMap := &map[string]interface{}{
|
||||||
|
"company": expressCompanyNo,
|
||||||
|
"number": expressNum,
|
||||||
|
"key": kdClient.AuthorizeKey,
|
||||||
|
"parameters": map[string]interface{}{
|
||||||
|
"callbackurl": "https://admin.deovo.com:9521/goadminapi/api/v1/express/state_push", // 正式环境
|
||||||
|
//"callbackurl": "https://dev.admin.deovo.com:9527/goadminapi/api/v1/express/state_push",// 测试环境
|
||||||
|
"salt": "FT1GHJ68798GJH3G",
|
||||||
|
"resultv2": 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
paramsBytes, err := json.Marshal(paramsMap)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("err:", err)
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
params := &url.Values{}
|
||||||
|
params.Set("schema", "json")
|
||||||
|
params.Set("param", string(paramsBytes))
|
||||||
|
|
||||||
|
err = kdClient.subscribePost("/poll?", params, resp)
|
||||||
|
if err != nil {
|
||||||
|
logger.Info("err", err)
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
respJson, _ := json.MarshalIndent(resp, "", " ")
|
||||||
|
//respJson, _ := json.Marshal(resp)
|
||||||
|
fmt.Println("respJson:", string(respJson))
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ func TestWebPay(t *testing.T) {
|
||||||
uid := "62389201"
|
uid := "62389201"
|
||||||
totalFee := uint32(100)
|
totalFee := uint32(100)
|
||||||
user := model.User{WxOpenID: "ohuHh4tpfro8u_fUPMbHEWYx5svQ"}
|
user := model.User{WxOpenID: "ohuHh4tpfro8u_fUPMbHEWYx5svQ"}
|
||||||
webPay, err := WebPay(uid, totalFee, user.WxOpenID, "N", WxPayMember)
|
webPay, err := WebPay(uid, totalFee, user.WxOpenID, "N", WxPayMember, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("err:", err)
|
fmt.Println("err:", err)
|
||||||
|
|
||||||
|
@ -46,5 +46,5 @@ func TestWebPay(t *testing.T) {
|
||||||
|
|
||||||
func TestWxPayTransactionOrderClose(t *testing.T) {
|
func TestWxPayTransactionOrderClose(t *testing.T) {
|
||||||
|
|
||||||
WxPayTransactionOrderClose("100000","1609877389")
|
WxPayTransactionOrderClose("100000", "1609877389")
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,8 @@ type CooperativeMemberPromotionStoreDay struct {
|
||||||
PlatinumCount uint32 `json:"platinum_count"` // 白金会员数量
|
PlatinumCount uint32 `json:"platinum_count"` // 白金会员数量
|
||||||
BlackGoldCount uint32 `json:"black_gold_count"` // 黑金会员数量
|
BlackGoldCount uint32 `json:"black_gold_count"` // 黑金会员数量
|
||||||
DayTime string `json:"day_time" gorm:"index"` //
|
DayTime string `json:"day_time" gorm:"index"` //
|
||||||
//
|
|
||||||
|
// cooperative_member_promotion_store_day
|
||||||
}
|
}
|
||||||
|
|
||||||
// gen:qs
|
// gen:qs
|
||||||
|
@ -147,6 +148,10 @@ func AddCooperativeMemberPromotion(cooperativeId, storeId, assistantUid uint32,
|
||||||
logger.Error("cooperative business err:", err)
|
logger.Error("cooperative business err:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
//fmt.Println("cooperativeId:", cooperativeId)
|
||||||
|
//fmt.Println("storeId:", storeId)
|
||||||
|
//fmt.Println("assistantUid:", assistantUid)
|
||||||
|
//fmt.Println("memberLevel:", memberLevel)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
promotion := &CooperativeMemberPromotion{CooperativeBusinessId: cooperativeId, CooperativeName: cooperativeBusiness.Name}
|
promotion := &CooperativeMemberPromotion{CooperativeBusinessId: cooperativeId, CooperativeName: cooperativeBusiness.Name}
|
||||||
|
@ -157,7 +162,7 @@ func AddCooperativeMemberPromotion(cooperativeId, storeId, assistantUid uint32,
|
||||||
Uid: assistantUid, StoreId: storeId,
|
Uid: assistantUid, StoreId: storeId,
|
||||||
}
|
}
|
||||||
begin := DB.Begin()
|
begin := DB.Begin()
|
||||||
err := promotion.AddPromotion(begin, memberLevel)
|
err = promotion.AddPromotion(begin, memberLevel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
begin.Rollback()
|
begin.Rollback()
|
||||||
logger.Error("promotion add promotion err:", err)
|
logger.Error("promotion add promotion err:", err)
|
||||||
|
@ -210,25 +215,28 @@ func (m *CooperativeMemberPromotion) AddPromotion(gdb *gorm.DB, memberLevel int)
|
||||||
switch memberLevel {
|
switch memberLevel {
|
||||||
case 2:
|
case 2:
|
||||||
sql = "UPDATE cooperative_member_promotion SET gold_count=gold_count+1 " +
|
sql = "UPDATE cooperative_member_promotion SET gold_count=gold_count+1 " +
|
||||||
fmt.Sprintf("WHERE date=%s AND cooperative_business_id=%d", dateString, m.CooperativeBusinessId)
|
fmt.Sprintf("WHERE date='%s' AND cooperative_business_id=%d", dateString, m.CooperativeBusinessId)
|
||||||
m.GoldCount = 1
|
m.GoldCount = 1
|
||||||
case 4:
|
case 4:
|
||||||
sql = "UPDATE cooperative_member_promotion SET platinum_count=platinum_count+1 " +
|
sql = "UPDATE cooperative_member_promotion SET platinum_count=platinum_count+1 " +
|
||||||
fmt.Sprintf("WHERE date=%s AND cooperative_business_id=%d", dateString, m.CooperativeBusinessId)
|
fmt.Sprintf("WHERE date='%s' AND cooperative_business_id=%d", dateString, m.CooperativeBusinessId)
|
||||||
m.PlatinumCount = 1
|
m.PlatinumCount = 1
|
||||||
case 5:
|
case 5:
|
||||||
sql = "UPDATE cooperative_member_promotion SET black_gold_count=black_gold_count+1 " +
|
sql = "UPDATE cooperative_member_promotion SET black_gold_count=black_gold_count+1 " +
|
||||||
fmt.Sprintf("WHERE date=%s AND cooperative_business_id=%d", dateString, m.CooperativeBusinessId)
|
fmt.Sprintf("WHERE date='%s' AND cooperative_business_id=%d", dateString, m.CooperativeBusinessId)
|
||||||
m.BlackGoldCount = 1
|
m.BlackGoldCount = 1
|
||||||
}
|
}
|
||||||
fmt.Println("邀请会员sql:", sql)
|
fmt.Println("邀请会员sql:", sql)
|
||||||
exist, err := QueryRecordExist(fmt.Sprintf(
|
exist, err := QueryRecordExist(fmt.Sprintf(
|
||||||
"SELECT * FROM cooperative_member_promotion WHERE cooperative_business_id=%d AND date=%s",
|
"SELECT * FROM cooperative_member_promotion WHERE cooperative_business_id=%d AND date='%s'",
|
||||||
m.CooperativeBusinessId, dateString))
|
m.CooperativeBusinessId, dateString))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("cooperative member promotion record exist err:", err)
|
logger.Error("cooperative member promotion record exist err:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
//fmt.Println("是否存在数据:", fmt.Sprintf(
|
||||||
|
// "SELECT * FROM cooperative_member_promotion WHERE cooperative_business_id=%d AND date='%s'",
|
||||||
|
// m.CooperativeBusinessId, dateString))
|
||||||
if exist {
|
if exist {
|
||||||
err = gdb.Exec(sql).Error
|
err = gdb.Exec(sql).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -257,22 +265,22 @@ func (m *CooperativeMemberPromotionStore) AddPromotion(gdb *gorm.DB, memberLevel
|
||||||
switch memberLevel {
|
switch memberLevel {
|
||||||
case 2:
|
case 2:
|
||||||
sql = "UPDATE cooperative_member_promotion_store SET gold_count=gold_count+1 " +
|
sql = "UPDATE cooperative_member_promotion_store SET gold_count=gold_count+1 " +
|
||||||
fmt.Sprintf("WHERE date=%s AND cooperative_business_id=%d AND store_id=%d",
|
fmt.Sprintf("WHERE date='%s' AND cooperative_business_id=%d AND store_id=%d",
|
||||||
dateString, m.CooperativeBusinessId, storeId)
|
dateString, m.CooperativeBusinessId, storeId)
|
||||||
m.GoldCount = 1
|
m.GoldCount = 1
|
||||||
case 4:
|
case 4:
|
||||||
sql = "UPDATE cooperative_member_promotion_store SET platinum_count=platinum_count+1 " +
|
sql = "UPDATE cooperative_member_promotion_store SET platinum_count=platinum_count+1 " +
|
||||||
fmt.Sprintf("WHERE date=%s AND cooperative_business_id=%d AND store_id=%d",
|
fmt.Sprintf("WHERE date='%s' AND cooperative_business_id=%d AND store_id=%d",
|
||||||
dateString, m.CooperativeBusinessId, storeId)
|
dateString, m.CooperativeBusinessId, storeId)
|
||||||
m.PlatinumCount = 1
|
m.PlatinumCount = 1
|
||||||
case 5:
|
case 5:
|
||||||
sql = "UPDATE cooperative_member_promotion_store SET black_gold_count=black_gold_count+1 " +
|
sql = "UPDATE cooperative_member_promotion_store SET black_gold_count=black_gold_count+1 " +
|
||||||
fmt.Sprintf("WHERE date=%s AND cooperative_business_id=%d AND store_id=%d",
|
fmt.Sprintf("WHERE date='%s' AND cooperative_business_id=%d AND store_id=%d",
|
||||||
dateString, m.CooperativeBusinessId, storeId)
|
dateString, m.CooperativeBusinessId, storeId)
|
||||||
m.BlackGoldCount = 1
|
m.BlackGoldCount = 1
|
||||||
}
|
}
|
||||||
exist, err := QueryRecordExist(fmt.Sprintf(
|
exist, err := QueryRecordExist(fmt.Sprintf(
|
||||||
"SELECT * FROM cooperative_member_promotion_store WHERE cooperative_business_id=%d AND date=%s AND store_id=%d",
|
"SELECT * FROM cooperative_member_promotion_store WHERE cooperative_business_id=%d AND date='%s' AND store_id=%d",
|
||||||
m.CooperativeBusinessId, dateString, storeId))
|
m.CooperativeBusinessId, dateString, storeId))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("cooperative member promotion record exist err:", err)
|
logger.Error("cooperative member promotion record exist err:", err)
|
||||||
|
@ -304,19 +312,19 @@ func (m *CooperativeMemberPromotionDay) AddPromotion(gdb *gorm.DB, memberLevel i
|
||||||
switch memberLevel {
|
switch memberLevel {
|
||||||
case 2:
|
case 2:
|
||||||
sql = "UPDATE cooperative_member_promotion_day SET gold_count=gold_count+1 " +
|
sql = "UPDATE cooperative_member_promotion_day SET gold_count=gold_count+1 " +
|
||||||
fmt.Sprintf("WHERE day_time=%s AND cooperative_business_id=%d", dayString, m.CooperativeBusinessId)
|
fmt.Sprintf("WHERE day_time='%s' AND cooperative_business_id=%d", dayString, m.CooperativeBusinessId)
|
||||||
m.GoldCount = 1
|
m.GoldCount = 1
|
||||||
case 4:
|
case 4:
|
||||||
sql = "UPDATE cooperative_member_promotion_day SET platinum_count=platinum_count+1 " +
|
sql = "UPDATE cooperative_member_promotion_day SET platinum_count=platinum_count+1 " +
|
||||||
fmt.Sprintf("WHERE day_time=%s AND cooperative_business_id=%d", dayString, m.CooperativeBusinessId)
|
fmt.Sprintf("WHERE day_time='%s' AND cooperative_business_id=%d", dayString, m.CooperativeBusinessId)
|
||||||
m.PlatinumCount = 1
|
m.PlatinumCount = 1
|
||||||
case 5:
|
case 5:
|
||||||
sql = "UPDATE cooperative_member_promotion_day SET black_gold_count=black_gold_count+1 " +
|
sql = "UPDATE cooperative_member_promotion_day SET black_gold_count=black_gold_count+1 " +
|
||||||
fmt.Sprintf("WHERE day_time=%s AND cooperative_business_id=%d", dayString, m.CooperativeBusinessId)
|
fmt.Sprintf("WHERE day_time='%s' AND cooperative_business_id=%d", dayString, m.CooperativeBusinessId)
|
||||||
m.BlackGoldCount = 1
|
m.BlackGoldCount = 1
|
||||||
}
|
}
|
||||||
exist, err := QueryRecordExist(fmt.Sprintf(
|
exist, err := QueryRecordExist(fmt.Sprintf(
|
||||||
"SELECT * FROM cooperative_member_promotion_day WHERE cooperative_business_id=%d AND day_time=%s",
|
"SELECT * FROM cooperative_member_promotion_day WHERE cooperative_business_id=%d AND day_time='%s'",
|
||||||
m.CooperativeBusinessId, dayString))
|
m.CooperativeBusinessId, dayString))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("cooperative member promotion record exist err:", err)
|
logger.Error("cooperative member promotion record exist err:", err)
|
||||||
|
@ -349,22 +357,22 @@ func (m *CooperativeMemberPromotionStoreDay) AddPromotion(gdb *gorm.DB, memberLe
|
||||||
switch memberLevel {
|
switch memberLevel {
|
||||||
case 2:
|
case 2:
|
||||||
sql = "UPDATE cooperative_member_promotion_store_day SET gold_count=gold_count+1 " +
|
sql = "UPDATE cooperative_member_promotion_store_day SET gold_count=gold_count+1 " +
|
||||||
fmt.Sprintf("WHERE day_time=%s AND cooperative_business_id=%d AND store_id=%d",
|
fmt.Sprintf("WHERE day_time='%s' AND cooperative_business_id=%d AND store_id=%d",
|
||||||
dateString, m.CooperativeBusinessId, storeId)
|
dateString, m.CooperativeBusinessId, storeId)
|
||||||
m.GoldCount = 1
|
m.GoldCount = 1
|
||||||
case 4:
|
case 4:
|
||||||
sql = "UPDATE cooperative_member_promotion_store_day SET platinum_count=platinum_count+1 " +
|
sql = "UPDATE cooperative_member_promotion_store_day SET platinum_count=platinum_count+1 " +
|
||||||
fmt.Sprintf("WHERE day_time=%s AND cooperative_business_id=%d AND store_id=%d",
|
fmt.Sprintf("WHERE day_time='%s' AND cooperative_business_id=%d AND store_id=%d",
|
||||||
dateString, m.CooperativeBusinessId, storeId)
|
dateString, m.CooperativeBusinessId, storeId)
|
||||||
m.PlatinumCount = 1
|
m.PlatinumCount = 1
|
||||||
case 5:
|
case 5:
|
||||||
sql = "UPDATE cooperative_member_promotion_store_day SET black_gold_count=black_gold_count+1 " +
|
sql = "UPDATE cooperative_member_promotion_store_day SET black_gold_count=black_gold_count+1 " +
|
||||||
fmt.Sprintf("WHERE day_time=%s AND cooperative_business_id=%d AND store_id=%d",
|
fmt.Sprintf("WHERE day_time='%s' AND cooperative_business_id=%d AND store_id=%d",
|
||||||
dateString, m.CooperativeBusinessId, storeId)
|
dateString, m.CooperativeBusinessId, storeId)
|
||||||
m.BlackGoldCount = 1
|
m.BlackGoldCount = 1
|
||||||
}
|
}
|
||||||
exist, err := QueryRecordExist("SELECT * FROM cooperative_member_promotion_store_day " +
|
exist, err := QueryRecordExist("SELECT * FROM cooperative_member_promotion_store_day " +
|
||||||
fmt.Sprintf("WHERE cooperative_business_id=%d AND day_time=%s AND store_id=%d",
|
fmt.Sprintf("WHERE cooperative_business_id=%d AND day_time='%s' AND store_id=%d",
|
||||||
m.CooperativeBusinessId, dateString, storeId))
|
m.CooperativeBusinessId, dateString, storeId))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("cooperative member promotion store day record exist err:", err)
|
logger.Error("cooperative member promotion store day record exist err:", err)
|
||||||
|
@ -405,23 +413,23 @@ func (m *InviteMemberReport) AddPromotion(gdb *gorm.DB, memberLevel int) error {
|
||||||
switch memberLevel {
|
switch memberLevel {
|
||||||
case 2:
|
case 2:
|
||||||
sql = "UPDATE invite_member_report SET gold_count=gold_count+1 " +
|
sql = "UPDATE invite_member_report SET gold_count=gold_count+1 " +
|
||||||
fmt.Sprintf("WHERE report_time=%s AND cooperative_business_id=%d AND store_id=%d AND uid=%d",
|
fmt.Sprintf("WHERE report_time='%s' AND cooperative_business_id=%d AND store_id=%d AND uid=%d",
|
||||||
dateString, m.CooperativeBusinessId, m.StoreId, m.Uid)
|
dateString, m.CooperativeBusinessId, m.StoreId, m.Uid)
|
||||||
m.GoldCount = 1
|
m.GoldCount = 1
|
||||||
case 4:
|
case 4:
|
||||||
sql = "UPDATE invite_member_report SET platinum_count=platinum_count+1 " +
|
sql = "UPDATE invite_member_report SET platinum_count=platinum_count+1 " +
|
||||||
fmt.Sprintf("WHERE report_time=%s AND cooperative_business_id=%d AND store_id=%d AND uid=%d",
|
fmt.Sprintf("WHERE report_time='%s' AND cooperative_business_id=%d AND store_id=%d AND uid=%d",
|
||||||
dateString, m.CooperativeBusinessId, m.StoreId, m.Uid)
|
dateString, m.CooperativeBusinessId, m.StoreId, m.Uid)
|
||||||
m.PlatinumCount = 1
|
m.PlatinumCount = 1
|
||||||
case 5:
|
case 5:
|
||||||
sql = "UPDATE invite_member_report SET black_gold_count=black_gold_count+1 " +
|
sql = "UPDATE invite_member_report SET black_gold_count=black_gold_count+1 " +
|
||||||
fmt.Sprintf("WHERE report_time=%s AND cooperative_business_id=%d AND store_id=%d AND uid=%d",
|
fmt.Sprintf("WHERE report_time='%s' AND cooperative_business_id=%d AND store_id=%d AND uid=%d",
|
||||||
dateString, m.CooperativeBusinessId, m.StoreId, m.Uid)
|
dateString, m.CooperativeBusinessId, m.StoreId, m.Uid)
|
||||||
m.BlackGoldCount = 1
|
m.BlackGoldCount = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
exist, err := QueryRecordExist(fmt.Sprintf(
|
exist, err := QueryRecordExist(fmt.Sprintf(
|
||||||
"SELECT * FROM invite_member_report WHERE cooperative_business_id=%d AND report_time=%s AND store_id=%d AND uid=%d",
|
"SELECT * FROM invite_member_report WHERE cooperative_business_id=%d AND report_time='%s' AND store_id=%d AND uid=%d",
|
||||||
m.CooperativeBusinessId, dateString, m.StoreId, m.Uid))
|
m.CooperativeBusinessId, dateString, m.StoreId, m.Uid))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("cooperative member promotion record exist err:", err)
|
logger.Error("cooperative member promotion record exist err:", err)
|
||||||
|
|
|
@ -665,8 +665,13 @@ func (m *CooperativeRentCardOrderListReq) List() ([]Order, int, error) {
|
||||||
m.PageSize = 10
|
m.PageSize = 10
|
||||||
}
|
}
|
||||||
assistant := GetUserByUid(m.AssistantUid)
|
assistant := GetUserByUid(m.AssistantUid)
|
||||||
m.StoreId = assistant.StoreId
|
if m.SerialNumber == "" {
|
||||||
qs := NewOrderQuerySet(DB).PayStatusEq(2).StoreIdEq(m.StoreId)
|
m.StoreId = assistant.StoreId
|
||||||
|
}
|
||||||
|
if assistant.UserType != 2 {
|
||||||
|
return orders, 0, errors.New("not assistant")
|
||||||
|
}
|
||||||
|
qs := NewOrderQuerySet(DB).PayStatusEq(2)
|
||||||
isDeliver := true
|
isDeliver := true
|
||||||
if m.SerialNumber != "" {
|
if m.SerialNumber != "" {
|
||||||
isDeliver = false
|
isDeliver = false
|
||||||
|
@ -717,7 +722,9 @@ func (m *CooperativeRentCardOrderListReq) List() ([]Order, int, error) {
|
||||||
if !m.EndTime.IsZero() {
|
if !m.EndTime.IsZero() {
|
||||||
qs = qs.CreatedAtLte(m.EndTime)
|
qs = qs.CreatedAtLte(m.EndTime)
|
||||||
}
|
}
|
||||||
|
if m.StoreId != 0 {
|
||||||
|
qs = qs.StoreIdEq(m.StoreId)
|
||||||
|
}
|
||||||
count, err := qs.Count()
|
count, err := qs.Count()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("err:%#v", err)
|
logger.Errorf("err:%#v", err)
|
||||||
|
@ -771,12 +778,13 @@ func (m *CooperativeRentCardOrderListReq) List() ([]Order, int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GameCardGoodsStockAnalysisReq struct {
|
type GameCardGoodsStockAnalysisReq struct {
|
||||||
SortType uint32 `json:"sort_type"` // 1-总库存 2-库存 3-用户持有 4-订单数量
|
Name string `json:"name"`
|
||||||
SortDirection uint32 `json:"sort_direction"` // 1-升序 2-降序
|
SortType uint32 `json:"sort_type"` // 1-总库存 2-库存 3-用户持有 4-订单数量
|
||||||
StoreId uint32 `json:"store_id"`
|
SortDirection uint32 `json:"sort_direction"` // 1-升序 2-降序
|
||||||
PageNum int `json:"page_num"`
|
CooperativeBusinessId uint32 `json:"cooperative_business_id"` // 合作商id
|
||||||
PageSize int `json:"page_size"`
|
StoreId uint32 `json:"store_id"`
|
||||||
Name string `json:"name"`
|
PageNum int `json:"page_num"`
|
||||||
|
PageSize int `json:"page_size"`
|
||||||
}
|
}
|
||||||
type GameCardGoodsStockAnalysisResp struct {
|
type GameCardGoodsStockAnalysisResp struct {
|
||||||
List []GameCardGoodsStock `json:"list"`
|
List []GameCardGoodsStock `json:"list"`
|
||||||
|
@ -812,7 +820,7 @@ func (m *GameCardGoodsStockAnalysisReq) GameCardStockListAnalysis() (*GameCardGo
|
||||||
} else if m.SortDirection == 2 {
|
} else if m.SortDirection == 2 {
|
||||||
sqlOrder += " ASC"
|
sqlOrder += " ASC"
|
||||||
}
|
}
|
||||||
sqlStore := ""
|
sqlStore := fmt.Sprintf(" AND cooperative_business_id = %d", m.CooperativeBusinessId)
|
||||||
if m.StoreId != 0 {
|
if m.StoreId != 0 {
|
||||||
sqlStore = fmt.Sprintf(" AND store_id = %d", m.StoreId)
|
sqlStore = fmt.Sprintf(" AND store_id = %d", m.StoreId)
|
||||||
}
|
}
|
||||||
|
@ -824,13 +832,13 @@ func (m *GameCardGoodsStockAnalysisReq) GameCardStockListAnalysis() (*GameCardGo
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
fmt.Println("--sqlName:", sqlName)
|
//fmt.Println("--sqlName:", sqlName)
|
||||||
gameIds := make([]string, 0)
|
gameIds := make([]string, 0)
|
||||||
for i, _ := range gameCards {
|
for i, _ := range gameCards {
|
||||||
gameIds = append(gameIds, fmt.Sprintf("%d", gameCards[i].ID))
|
gameIds = append(gameIds, fmt.Sprintf("%d", gameCards[i].ID))
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("--gameIds:", gameIds)
|
//fmt.Println("--gameIds:", gameIds)
|
||||||
sqlStore += fmt.Sprintf(" AND game_card_id IN (%s)", strings.Join(gameIds, ","))
|
sqlStore += fmt.Sprintf(" AND game_card_id IN (%s)", strings.Join(gameIds, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1491,6 +1499,9 @@ func (m *AssistantMemberPromotionReq) List() ([]InviteMemberReport, int, error)
|
||||||
|
|
||||||
qs := NewInviteMemberReportQuerySet(DB).CooperativeBusinessIdEq(m.Assistant.CooperativeBusinessId).
|
qs := NewInviteMemberReportQuerySet(DB).CooperativeBusinessIdEq(m.Assistant.CooperativeBusinessId).
|
||||||
StoreIdEq(m.StoreId)
|
StoreIdEq(m.StoreId)
|
||||||
|
if m.Date != "" {
|
||||||
|
qs = qs.ReportTimeEq(m.Date)
|
||||||
|
}
|
||||||
count, err := qs.Count()
|
count, err := qs.Count()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("err:", err)
|
logger.Error("err:", err)
|
||||||
|
@ -1503,5 +1514,25 @@ func (m *AssistantMemberPromotionReq) List() ([]InviteMemberReport, int, error)
|
||||||
return reports, totalPage, err
|
return reports, totalPage, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reports = InviteMemberReportListSetUser(reports)
|
||||||
return reports, totalPage, nil
|
return reports, totalPage, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func InviteMemberReportListSetUser(list []InviteMemberReport) []InviteMemberReport {
|
||||||
|
uids := make([]uint32, 0, len(list))
|
||||||
|
for i, _ := range list {
|
||||||
|
uids = append(uids, list[i].Uid)
|
||||||
|
}
|
||||||
|
userMap, err := GetUserMap(uids)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("user map err:", err)
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
for i, _ := range list {
|
||||||
|
v, ok := userMap[list[i].Uid]
|
||||||
|
if ok {
|
||||||
|
list[i].User = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
|
@ -95,6 +95,7 @@ func InitTestDB() {
|
||||||
&CooperativeBusiness{},
|
&CooperativeBusiness{},
|
||||||
&CooperativeMemberDeduct{},
|
&CooperativeMemberDeduct{},
|
||||||
&CooperativeAssistantMemberDeduct{},
|
&CooperativeAssistantMemberDeduct{},
|
||||||
|
|
||||||
&CooperativeMemberPromotion{},
|
&CooperativeMemberPromotion{},
|
||||||
&CooperativeMemberPromotionStore{},
|
&CooperativeMemberPromotionStore{},
|
||||||
&CooperativeMemberPromotionDay{},
|
&CooperativeMemberPromotionDay{},
|
||||||
|
@ -137,31 +138,31 @@ func InitDBProd() {
|
||||||
DBProd.LogMode(false)
|
DBProd.LogMode(false)
|
||||||
DBProd.SingularTable(true)
|
DBProd.SingularTable(true)
|
||||||
DBProd.AutoMigrate(
|
DBProd.AutoMigrate(
|
||||||
//&RedeemCode{},
|
//&RedeemCode{},
|
||||||
//&UserRedeemCode{},
|
//&UserRedeemCode{},
|
||||||
//&GameCardGoods{},
|
//&GameCardGoods{},
|
||||||
//
|
//
|
||||||
//&UserShareCardBill{},
|
//&UserShareCardBill{},
|
||||||
//&ShareCardBillGame{},
|
//&ShareCardBillGame{},
|
||||||
//&UserShareCard{},
|
//&UserShareCard{},
|
||||||
//&ShareCardVmRecord{},
|
//&ShareCardVmRecord{},
|
||||||
//&UserShareCardVm{},
|
//&UserShareCardVm{},
|
||||||
//&ShareCardDateVm{},
|
//&ShareCardDateVm{},
|
||||||
//&ShareCardGameVm{},
|
//&ShareCardGameVm{},
|
||||||
//&ShareCardRetrieve{},
|
//&ShareCardRetrieve{},
|
||||||
//&ShareCardRetrieveCard{},
|
//&ShareCardRetrieveCard{},
|
||||||
//&GameCardLabel{},
|
//&GameCardLabel{},
|
||||||
//&CardIssueFeedback{},
|
//&CardIssueFeedback{},
|
||||||
|
|
||||||
//&GameCard{},
|
//&GameCard{},
|
||||||
//&FundRecord{},
|
//&FundRecord{},
|
||||||
//&User{},
|
//&User{},
|
||||||
|
|
||||||
//&GameCard{},
|
//&GameCard{},
|
||||||
//&FundRecord{},
|
//&FundRecord{},
|
||||||
//&User{},
|
//&User{},
|
||||||
//&UserAttendance{},
|
//&UserAttendance{},
|
||||||
//&UserAttendanceRecord{},
|
//&UserAttendanceRecord{},
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1158,3 +1159,9 @@ func TestExportGoodsStock(t *testing.T) {
|
||||||
fmt.Println("stock:", stock)
|
fmt.Println("stock:", stock)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAddCooperativeMemberPromotion(t *testing.T) {
|
||||||
|
InitTestDB()
|
||||||
|
DB = DBDev
|
||||||
|
AddCooperativeMemberPromotion(4, 20, 68608411, 2)
|
||||||
|
}
|
||||||
|
|
104
model/order.go
104
model/order.go
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"mh-server/kuaidi"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -108,6 +109,7 @@ type OrderCard struct {
|
||||||
Order *Order `json:"order" gorm:"-"` // 订单
|
Order *Order `json:"order" gorm:"-"` // 订单
|
||||||
GameCard *GameCard `json:"game_card" gorm:"-"` // 游戏
|
GameCard *GameCard `json:"game_card" gorm:"-"` // 游戏
|
||||||
Store *Store `json:"store" gorm:"-"` // 游戏
|
Store *Store `json:"store" gorm:"-"` // 游戏
|
||||||
|
RevertStore *Store `json:"revert_store" gorm:"-"` // 游戏
|
||||||
//Status uint8 `json:"status" gorm:"index"` // 1-待领取 2-游玩中 3-已归还 4-未领取
|
//Status uint8 `json:"status" gorm:"index"` // 1-待领取 2-游玩中 3-已归还 4-未领取
|
||||||
//PickupCode string `json:"pickup_code"` // 取货码
|
//PickupCode string `json:"pickup_code"` // 取货码
|
||||||
}
|
}
|
||||||
|
@ -910,8 +912,10 @@ func (m *CooperativeRentCardOrderReq) Info() (Order, error) {
|
||||||
|
|
||||||
func CooperativeOrderCardListSetInfo(list []OrderCard) []OrderCard {
|
func CooperativeOrderCardListSetInfo(list []OrderCard) []OrderCard {
|
||||||
ids := make([]uint32, 0, len(list))
|
ids := make([]uint32, 0, len(list))
|
||||||
|
storeIds := make([]uint32, 0, len(list))
|
||||||
for i, _ := range list {
|
for i, _ := range list {
|
||||||
ids = append(ids, list[i].GameCardId)
|
ids = append(ids, list[i].GameCardId)
|
||||||
|
storeIds = append(storeIds, uint32(list[i].RevertStoreId))
|
||||||
}
|
}
|
||||||
if len(ids) == 0 {
|
if len(ids) == 0 {
|
||||||
return list
|
return list
|
||||||
|
@ -919,10 +923,14 @@ func CooperativeOrderCardListSetInfo(list []OrderCard) []OrderCard {
|
||||||
|
|
||||||
cardMap, err := GameCardMap(ids)
|
cardMap, err := GameCardMap(ids)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("err:", err)
|
logger.Error("game card map err:", err)
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
storeMap, err := GetStoreMap(storeIds)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("store map err:", err)
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, _ := range list {
|
for i, _ := range list {
|
||||||
gameCard, ok1 := cardMap[list[i].GameCardId]
|
gameCard, ok1 := cardMap[list[i].GameCardId]
|
||||||
if ok1 {
|
if ok1 {
|
||||||
|
@ -930,6 +938,11 @@ func CooperativeOrderCardListSetInfo(list []OrderCard) []OrderCard {
|
||||||
list[i].GameCoverImg = gameCard.CoverImg
|
list[i].GameCoverImg = gameCard.CoverImg
|
||||||
list[i].GamePrice = gameCard.Price
|
list[i].GamePrice = gameCard.Price
|
||||||
}
|
}
|
||||||
|
|
||||||
|
revertStore, ok2 := storeMap[uint32(list[i].RevertStoreId)]
|
||||||
|
if ok2 {
|
||||||
|
list[i].RevertStore = &revertStore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list
|
return list
|
||||||
|
@ -1011,10 +1024,9 @@ type CooperativeRentCardOrderDeliverReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
||||||
paraMap := make(map[string]interface{}, 0)
|
|
||||||
order := new(Order)
|
order := new(Order)
|
||||||
order.ID = m.OrderId
|
order.ID = m.OrderId
|
||||||
|
|
||||||
err := order.GetById()
|
err := order.GetById()
|
||||||
if err != nil && err != RecordNotFound {
|
if err != nil && err != RecordNotFound {
|
||||||
logger.Error("err:", err)
|
logger.Error("err:", err)
|
||||||
|
@ -1025,6 +1037,7 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
||||||
logger.Error("err:", err)
|
logger.Error("err:", err)
|
||||||
return err, ""
|
return err, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(m.SerialNumbers) != len(order.OrderCards) || len(m.SerialNumbers) == 0 {
|
if len(m.SerialNumbers) != len(order.OrderCards) || len(m.SerialNumbers) == 0 {
|
||||||
logger.Error("发货卡的数量与订单游戏卡数量不一致")
|
logger.Error("发货卡的数量与订单游戏卡数量不一致")
|
||||||
return errors.New("发货卡的数量与订单游戏卡数量不一致"), "发货卡的数量与订单游戏卡数量不一致"
|
return errors.New("发货卡的数量与订单游戏卡数量不一致"), "发货卡的数量与订单游戏卡数量不一致"
|
||||||
|
@ -1040,10 +1053,12 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
||||||
for i, _ := range order.OrderCards {
|
for i, _ := range order.OrderCards {
|
||||||
orderCardMaps[order.OrderCards[i].ID] = order.OrderCards[i]
|
orderCardMaps[order.OrderCards[i].ID] = order.OrderCards[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
receiptTime := time.Time{}
|
receiptTime := time.Time{}
|
||||||
if order.DeliveryType == 1 {
|
if order.DeliveryType == 1 {
|
||||||
receiptTime = time.Now()
|
receiptTime = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
serialNumberMap := make(map[string]GameCardGoods, 0)
|
serialNumberMap := make(map[string]GameCardGoods, 0)
|
||||||
var serialGoods []GameCardGoods
|
var serialGoods []GameCardGoods
|
||||||
err = NewGameCardGoodsQuerySet(DB).SerialNumberIn(m.SerialNumbers...).All(&serialGoods)
|
err = NewGameCardGoodsQuerySet(DB).SerialNumberIn(m.SerialNumbers...).All(&serialGoods)
|
||||||
|
@ -1058,11 +1073,11 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
||||||
isUpdateOrder := false
|
isUpdateOrder := false
|
||||||
begin := DB.Begin()
|
begin := DB.Begin()
|
||||||
for _, serialNumber := range m.SerialNumbers {
|
for _, serialNumber := range m.SerialNumbers {
|
||||||
if serialNumber != "" {
|
if serialNumber == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
paraMap["game_card_serial_number"] = serialNumber
|
|
||||||
gameCardGoods, ok := serialNumberMap["serialNumber"]
|
gameCardGoods, ok := serialNumberMap[serialNumber]
|
||||||
if !ok {
|
if !ok {
|
||||||
begin.Rollback()
|
begin.Rollback()
|
||||||
logger.Errorf("游戏编号卡未找到:%s", serialNumber)
|
logger.Errorf("游戏编号卡未找到:%s", serialNumber)
|
||||||
|
@ -1102,13 +1117,16 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
||||||
return errors.New("游戏编号卡不是该门店"), "该门店没有改游戏卡"
|
return errors.New("游戏编号卡不是该门店"), "该门店没有改游戏卡"
|
||||||
}
|
}
|
||||||
|
|
||||||
if uint32(m.StoreId) != orderCard.StoreId {
|
if (m.StoreId) != orderCard.StoreId {
|
||||||
begin.Rollback()
|
begin.Rollback()
|
||||||
// 订单锁库存
|
// 订单锁库存
|
||||||
logger.Error("订单门店与发货门店不一致")
|
logger.Error("订单门店与发货门店不一致")
|
||||||
return errors.New("订单门店与发货门店不一致"), "订单门店与发货门店不一致,请取消订单后重新下单"
|
return errors.New("订单门店与发货门店不一致"), "订单门店与发货门店不一致,请取消订单后重新下单"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paraMap := make(map[string]interface{}, 0)
|
||||||
|
//paraMap["game_card_serial_number"] = serialNumber
|
||||||
|
|
||||||
if !isUpdateOrder {
|
if !isUpdateOrder {
|
||||||
if m.StoreId != 0 {
|
if m.StoreId != 0 {
|
||||||
paraMap["store_id"] = m.StoreId
|
paraMap["store_id"] = m.StoreId
|
||||||
|
@ -1126,7 +1144,7 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
||||||
if m.ExpressNo != "" {
|
if m.ExpressNo != "" {
|
||||||
paraMap["express_no"] = m.ExpressNo
|
paraMap["express_no"] = m.ExpressNo
|
||||||
}
|
}
|
||||||
err := begin.Table("order").Where("id", m.OrderId).Updates(paraMap).Error
|
err := begin.Table("order").Where("id=?", m.OrderId).Updates(paraMap).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
begin.Rollback()
|
begin.Rollback()
|
||||||
logger.Error("err:", err)
|
logger.Error("err:", err)
|
||||||
|
@ -1137,7 +1155,7 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
||||||
|
|
||||||
var eg errgroup.Group
|
var eg errgroup.Group
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
err := begin.Table("game_card_goods").Where("serial_number", serialNumber).
|
err := begin.Table("game_card_goods").Where("serial_number=?", serialNumber).
|
||||||
Update("status", GameCardGoodsStatusCustomerHold).Error
|
Update("status", GameCardGoodsStatusCustomerHold).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
begin.Rollback()
|
begin.Rollback()
|
||||||
|
@ -1173,7 +1191,7 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
err = begin.Table("order_card").Where("id=?", orderCard.ID).Updates(&map[string]interface{}{
|
err = begin.Table("order_card").Where("id=?", orderCard.ID).Updates(map[string]interface{}{
|
||||||
"store_id": m.StoreId,
|
"store_id": m.StoreId,
|
||||||
"delivery_time": time.Now(),
|
"delivery_time": time.Now(),
|
||||||
"game_card_goods_id": gameCardGoods.ID,
|
"game_card_goods_id": gameCardGoods.ID,
|
||||||
|
@ -1198,10 +1216,6 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = begin.Table("order_card").Where("order_id=?", m.OrderId).Where("uid=?", order.Uid).
|
|
||||||
Where("serial_number=''").Updates(&map[string]interface{}{
|
|
||||||
"card_status": 5,
|
|
||||||
}).Error
|
|
||||||
err = begin.Commit().Error
|
err = begin.Commit().Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
begin.Rollback()
|
begin.Rollback()
|
||||||
|
@ -1209,26 +1223,36 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
||||||
return err, ""
|
return err, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
err = DB.Table("order_card").Where("order_id=?", m.OrderId).Where("uid=?", order.Uid).
|
||||||
//if m.ExpressCompanyNo != "" && m.ExpressNo != "" {
|
Where("serial_number=''").Updates(&map[string]interface{}{
|
||||||
// _, err = kuaidi.SubscribeExpressState(m.ExpressCompanyNo, m.ExpressNo)
|
"card_status": 5,
|
||||||
// if err != nil {
|
}).Error
|
||||||
// logger.Error("subscribe express state err:", err)
|
if err != nil {
|
||||||
// }
|
logger.Error("err:", err)
|
||||||
//}
|
return err, ""
|
||||||
|
|
||||||
operationLog := &OperationLog{
|
|
||||||
Uid: m.OperationUid,
|
|
||||||
Description: "借卡归还入库",
|
|
||||||
OperationType: OperationTypeRentCardDeliver,
|
|
||||||
CorrelationId: order.ID,
|
|
||||||
CorrelationName: LogCorrelationOrderId,
|
|
||||||
StoreId: m.StoreId,
|
|
||||||
StoreName: "",
|
|
||||||
CooperativeName: "",
|
|
||||||
//SerialNumber: m.SerialNumber,
|
|
||||||
}
|
}
|
||||||
operationLog.AddLog()
|
|
||||||
|
go func() {
|
||||||
|
if m.ExpressCompanyNo != "" && m.ExpressNo != "" {
|
||||||
|
_, err = kuaidi.SubscribeExpressState(m.ExpressCompanyNo, m.ExpressNo)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("subscribe express state err:", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
operationLog := &OperationLog{
|
||||||
|
Uid: m.OperationUid,
|
||||||
|
Description: "借卡发货",
|
||||||
|
OperationType: OperationTypeRentCardDeliver,
|
||||||
|
CorrelationId: order.ID,
|
||||||
|
CorrelationName: LogCorrelationOrderId,
|
||||||
|
StoreId: m.StoreId,
|
||||||
|
StoreName: "",
|
||||||
|
CooperativeName: "",
|
||||||
|
//SerialNumber: m.SerialNumber,
|
||||||
|
}
|
||||||
|
operationLog.AddLog()
|
||||||
|
}()
|
||||||
|
|
||||||
return nil, ""
|
return nil, ""
|
||||||
}
|
}
|
||||||
|
@ -1336,8 +1360,8 @@ func (m *CooperativeRentCardOrderRevertReq) Revert() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
err := DB.Table("game_card_goods_stock").Where("store_id", m.RevertStoreId).
|
err := DB.Table("game_card_goods_stock").Where("store_id=?", m.RevertStoreId).
|
||||||
Where("game_card_id", gameCardGoods.GameCardId).Count(&count).Error
|
Where("game_card_id=?", gameCardGoods.GameCardId).Count(&count).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
begin.Rollback()
|
begin.Rollback()
|
||||||
logger.Error("err:", err)
|
logger.Error("err:", err)
|
||||||
|
@ -1410,7 +1434,7 @@ func (m *CooperativeRentCardOrderRevertReq) Revert() error {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
err := begin.Table("order_card").Where("id=?", orderCard.ID).Updates(&map[string]interface{}{
|
err := begin.Table("order_card").Where("id=?", orderCard.ID).Updates(map[string]interface{}{
|
||||||
"card_status": OrderCardStatusCompleted,
|
"card_status": OrderCardStatusCompleted,
|
||||||
"revert_store_id": m.RevertStoreId,
|
"revert_store_id": m.RevertStoreId,
|
||||||
"revert_time": time.Now(),
|
"revert_time": time.Now(),
|
||||||
|
@ -1429,7 +1453,7 @@ func (m *CooperativeRentCardOrderRevertReq) Revert() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
err := begin.Table("order").Where("id=?", orderCard.OrderId).Updates(&map[string]interface{}{
|
err := begin.Table("order").Where("id=?", orderCard.OrderId).Updates(map[string]interface{}{
|
||||||
"card_status": OrderCardStatusCompleted,
|
"card_status": OrderCardStatusCompleted,
|
||||||
}).Error
|
}).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1441,7 +1465,9 @@ func (m *CooperativeRentCardOrderRevertReq) Revert() error {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
sql := fmt.Sprintf("UPDATE user_rent_card SET have_rent_count = have_rent_count-1,can_rent_count=can_rent_count+1 WHERE uid =%d;", orderCard.Uid)
|
sql := fmt.Sprintf(
|
||||||
|
"UPDATE user_rent_card SET have_rent_count = have_rent_count-1,can_rent_count=can_rent_count+1 WHERE uid =%d;",
|
||||||
|
orderCard.Uid)
|
||||||
//sql := fmt.Sprintf("UPDATE user_rent_card SET have_rent_count = have_rent_count-1,can_rent_count=can_rent_count+1 WHERE uid =%d;", m.Uid)
|
//sql := fmt.Sprintf("UPDATE user_rent_card SET have_rent_count = have_rent_count-1,can_rent_count=can_rent_count+1 WHERE uid =%d;", m.Uid)
|
||||||
fmt.Println("sql:", sql)
|
fmt.Println("sql:", sql)
|
||||||
err = begin.Exec(sql).Error
|
err = begin.Exec(sql).Error
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/codinl/go-logger"
|
"github.com/codinl/go-logger"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
"time"
|
"time"
|
||||||
|
@ -54,7 +53,7 @@ func GetStoreList(cardInfos []CardInfo) ([]GameCardStock, error) {
|
||||||
|
|
||||||
if len(cardInfos) == 0 {
|
if len(cardInfos) == 0 {
|
||||||
stores = *<-storesCh
|
stores = *<-storesCh
|
||||||
fmt.Println("stores:", stores)
|
//fmt.Println("stores:", stores)
|
||||||
for i, _ := range stores {
|
for i, _ := range stores {
|
||||||
cardStock := GameCardStock{
|
cardStock := GameCardStock{
|
||||||
Store: stores[i],
|
Store: stores[i],
|
||||||
|
@ -126,7 +125,7 @@ func GetStoreList(cardInfos []CardInfo) ([]GameCardStock, error) {
|
||||||
// list = append(list, cardStock)
|
// list = append(list, cardStock)
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
fmt.Println("list:", list)
|
//fmt.Println("list:", list)
|
||||||
return list, nil
|
return list, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ type User struct {
|
||||||
StoreType uint32 `json:"store_type"` // 1-订单门店
|
StoreType uint32 `json:"store_type"` // 1-订单门店
|
||||||
CooperativeBusinessId uint32 `json:"cooperative_business_id" gorm:"index"` // 合作商id
|
CooperativeBusinessId uint32 `json:"cooperative_business_id" gorm:"index"` // 合作商id
|
||||||
CooperativeName string `json:"cooperative_name"` // 合作商名称
|
CooperativeName string `json:"cooperative_name"` // 合作商名称
|
||||||
|
ShopAssistantName string `json:"shop_assistant_name"` // 店员名称
|
||||||
Version uint32 `json:"-"`
|
Version uint32 `json:"-"`
|
||||||
UserVm *UserVm `json:"user_vm" gorm:"-"` //
|
UserVm *UserVm `json:"user_vm" gorm:"-"` //
|
||||||
//RoleId uint32 `json:"role_id"` // 角色id
|
//RoleId uint32 `json:"role_id"` // 角色id
|
||||||
|
@ -268,22 +269,26 @@ const (
|
||||||
LogCorrelationOrderCard = "order_card_id"
|
LogCorrelationOrderCard = "order_card_id"
|
||||||
)
|
)
|
||||||
const (
|
const (
|
||||||
OperationTypeRentCardRevert = "rent_card_revert"
|
OperationTypeRentCardRevert = "rent_card_revert"
|
||||||
OperationTypeRentCardDeliver = "rent_card_deliver"
|
OperationTypeRentCardDeliver = "rent_card_deliver"
|
||||||
|
OperationTypeGameCardGoodsInStock = "game_card_goods_in_stock" // 入库
|
||||||
)
|
)
|
||||||
|
|
||||||
// gen:qs
|
// gen:qs
|
||||||
type OperationLog struct {
|
type OperationLog struct {
|
||||||
Model
|
Model
|
||||||
Uid uint32 `json:"uid" gorm:"index"` // 店员id
|
Uid uint32 `json:"uid" gorm:"index"` // 店员id
|
||||||
Description string `json:"description"` // 描述
|
Description string `json:"description"` // 描述
|
||||||
OperationType string `json:"operation_type" gorm:"index"` // 操作类型
|
OperationType string `json:"operation_type" gorm:"index"` // 操作类型
|
||||||
CorrelationId uint32 `json:"correlation_id" gorm:"index"` // 关联id
|
CorrelationId uint32 `json:"correlation_id" gorm:"index"` // 关联id
|
||||||
CorrelationName string `json:"correlation_name" gorm:"index"` // 关联name
|
CorrelationName string `json:"correlation_name" gorm:"index"` // 关联name
|
||||||
StoreId uint32 `json:"store_id" gorm:"index"` // 门店id
|
StoreId uint32 `json:"store_id" gorm:"index"` // 门店id
|
||||||
StoreName string `json:"store_name"` // 门店名称
|
StoreName string `json:"store_name"` // 门店名称
|
||||||
CooperativeName string `json:"cooperative_name"` // 合作商名称
|
CooperativeName string `json:"cooperative_name"` // 合作商名称
|
||||||
SerialNumber string `json:"serial_number" gorm:"index"` // 卡编号
|
CooperativeBusinessId uint32 `json:"cooperative_business_id"` // 合作商id
|
||||||
|
SerialNumber string `json:"serial_number" gorm:"index"` // 卡编号
|
||||||
|
Detail string `json:"detail"` // 详情
|
||||||
|
Remark string `json:"remark"` // 备注
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *UserOpenMemberRecord) OrderRefund(outTradeNo string) error {
|
func (m *UserOpenMemberRecord) OrderRefund(outTradeNo string) error {
|
||||||
|
@ -321,6 +326,7 @@ type InviteMemberReport struct {
|
||||||
PlatinumDeduct uint32 `json:"platinum_deduct"` // 白金会员提成
|
PlatinumDeduct uint32 `json:"platinum_deduct"` // 白金会员提成
|
||||||
BlackGoldDeduct uint32 `json:"black_gold_deduct"` // 黑金会员提成
|
BlackGoldDeduct uint32 `json:"black_gold_deduct"` // 黑金会员提成
|
||||||
// invite_member_report
|
// invite_member_report
|
||||||
|
User *User `json:"user" gorm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *UserOpenMemberRecord) Refund(outTradeNo string, amount uint32) error {
|
func (m *UserOpenMemberRecord) Refund(outTradeNo string, amount uint32) error {
|
||||||
|
@ -896,12 +902,15 @@ func (m *InviteMemberReportListReq) List() ([]InviteMemberReport, int, error) {
|
||||||
cooperative := new(CooperativeBusiness)
|
cooperative := new(CooperativeBusiness)
|
||||||
cooperative.ID = assistant.CooperativeBusinessId
|
cooperative.ID = assistant.CooperativeBusinessId
|
||||||
cooperative.SetAssistantMemberDeductConfig(uint32(assistant.StoreId))
|
cooperative.SetAssistantMemberDeductConfig(uint32(assistant.StoreId))
|
||||||
|
fmt.Println("CooperativeBusinessId:", assistant.CooperativeBusinessId, assistant.StoreId)
|
||||||
|
fmt.Println("CooperativeAssistantMemberDeduct:", cooperative.CooperativeAssistantMemberDeduct)
|
||||||
if len(memberReport) > 0 {
|
if len(memberReport) > 0 {
|
||||||
memberReport[len(memberReport)-1].GoldDeduct = cooperative.CooperativeAssistantMemberDeduct.GoldDeduct
|
memberReport[len(memberReport)-1].GoldDeduct = cooperative.CooperativeAssistantMemberDeduct.GoldDeduct
|
||||||
memberReport[len(memberReport)-1].PlatinumDeduct = cooperative.CooperativeAssistantMemberDeduct.PlatinumDeduct
|
memberReport[len(memberReport)-1].PlatinumDeduct = cooperative.CooperativeAssistantMemberDeduct.PlatinumDeduct
|
||||||
memberReport[len(memberReport)-1].BlackGoldDeduct = cooperative.CooperativeAssistantMemberDeduct.BlackGoldDeduct
|
memberReport[len(memberReport)-1].BlackGoldDeduct = cooperative.CooperativeAssistantMemberDeduct.BlackGoldDeduct
|
||||||
|
|
||||||
report := memberReport[len(memberReport)-1]
|
report := memberReport[len(memberReport)-1]
|
||||||
|
fmt.Println("report:", report)
|
||||||
memberReport[len(memberReport)-1].DeductAmount += report.GoldCount * report.GoldDeduct
|
memberReport[len(memberReport)-1].DeductAmount += report.GoldCount * report.GoldDeduct
|
||||||
memberReport[len(memberReport)-1].DeductAmount += report.PlatinumCount * report.PlatinumDeduct
|
memberReport[len(memberReport)-1].DeductAmount += report.PlatinumCount * report.PlatinumDeduct
|
||||||
memberReport[len(memberReport)-1].DeductAmount += report.BlackGoldCount * report.BlackGoldDeduct
|
memberReport[len(memberReport)-1].DeductAmount += report.BlackGoldCount * report.BlackGoldDeduct
|
||||||
|
@ -909,3 +918,17 @@ func (m *InviteMemberReportListReq) List() ([]InviteMemberReport, int, error) {
|
||||||
|
|
||||||
return memberReport, totalPage, nil
|
return memberReport, totalPage, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUserMap(ids []uint32) (map[uint32]*User, error) {
|
||||||
|
userMap := make(map[uint32]*User, 0)
|
||||||
|
var users []User
|
||||||
|
err := NewUserQuerySet(DB).UidIn(ids...).All(&users)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("user err:", err)
|
||||||
|
return userMap, err
|
||||||
|
}
|
||||||
|
for i, _ := range users {
|
||||||
|
userMap[users[i].Uid] = &users[i]
|
||||||
|
}
|
||||||
|
return userMap, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user