fix:
This commit is contained in:
parent
133ed7db4b
commit
f3a8ac8a55
|
@ -25,11 +25,25 @@ func CooperativeGameCardGoodsStockAdds(c *gin.Context) {
|
|||
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
|
||||
}
|
||||
if assistant.XcxRoleId != 2 {
|
||||
logger.Error("not shop manager")
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
serialNumbers := ""
|
||||
cardGoods := &model.GameCardGoods{}
|
||||
for i, _ := range req.Cards {
|
||||
req.Cards[i].CardType = model.GameCardGoodsTypeCommon
|
||||
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)
|
||||
if err != nil {
|
||||
|
@ -38,6 +52,19 @@ func CooperativeGameCardGoodsStockAdds(c *gin.Context) {
|
|||
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)
|
||||
return
|
||||
}
|
||||
|
@ -49,7 +76,19 @@ func GameCardGoodsStockAnalysis(c *gin.Context) {
|
|||
RespJson(c, status.BadRequest, nil)
|
||||
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()
|
||||
if err != nil {
|
||||
logger.Error("err:", err)
|
||||
|
@ -78,7 +117,11 @@ func CooperativeExportDataGameCardGoodsStock(c *gin.Context) {
|
|||
RespJson(c, status.NoAuth, nil)
|
||||
return
|
||||
}
|
||||
|
||||
if assistant.UserType != 2 {
|
||||
logger.Error("not assistant")
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
goodsStock := model.ExportGoodsStock(uint32(assistant.StoreId))
|
||||
|
||||
ret := &map[string]interface{}{
|
||||
|
@ -107,6 +150,11 @@ func CooperativeCannibalizeTaskCreate(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
assistant := model.GetUserByUid(uc.Uid)
|
||||
if assistant.UserType != 2 {
|
||||
logger.Error("not assistant")
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
req.FromStoreId = uint32(assistant.StoreId)
|
||||
if req.FromStoreId == 0 || req.ToStoreId == 0 {
|
||||
RespJson(c, status.BadRequest, nil)
|
||||
|
@ -141,6 +189,19 @@ func CooperativeCannibalizeTaskImportGoods(c *gin.Context) {
|
|||
RespJson(c, status.BadRequest, nil)
|
||||
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)
|
||||
if err != nil {
|
||||
logger.Error("err:", err)
|
||||
|
@ -168,6 +229,18 @@ func CooperativeCannibalizeTaskDeliverGoods(c *gin.Context) {
|
|||
RespJson(c, status.BadRequest, nil)
|
||||
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)
|
||||
if err != nil {
|
||||
logger.Error("err:", err)
|
||||
|
@ -192,6 +265,18 @@ func CooperativeCannibalizeTaskPutInStorage(c *gin.Context) {
|
|||
RespJson(c, status.BadRequest, nil)
|
||||
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)
|
||||
if err != nil {
|
||||
logger.Error("err:", err)
|
||||
|
@ -219,6 +304,11 @@ func CooperativeCannibalizeTaskList(c *gin.Context) {
|
|||
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)
|
||||
if req.StoreId == 0 {
|
||||
RespJson(c, status.BadRequest, nil)
|
||||
|
@ -247,7 +337,18 @@ func CooperativeCannibalizeTaskGameCardGoodsList(c *gin.Context) {
|
|||
RespJson(c, status.BadRequest, nil)
|
||||
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()
|
||||
if err != nil {
|
||||
logger.Error("err:", err)
|
||||
|
@ -271,6 +372,18 @@ func CooperativeCannibalizeTaskDel(c *gin.Context) {
|
|||
RespJson(c, status.BadRequest, nil)
|
||||
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)
|
||||
if err != nil {
|
||||
logger.Error("err:", err)
|
||||
|
@ -300,7 +413,12 @@ func CooperativeGameCardGoodsList(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
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()
|
||||
if err != nil {
|
||||
logger.Error("list err:", err)
|
||||
|
@ -338,6 +456,11 @@ func AssistantMemberPromotionList(c *gin.Context) {
|
|||
RespJson(c, status.NoAuth, nil)
|
||||
return
|
||||
}
|
||||
if req.Assistant.UserType != 2 {
|
||||
logger.Error("not assistant")
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
list, totalPage, err := req.List()
|
||||
if err != nil {
|
||||
logger.Error("list err:", err)
|
||||
|
|
|
@ -53,6 +53,12 @@ func CooperativeRentCardOrderInfo(c *gin.Context) {
|
|||
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
|
||||
}
|
||||
order, err := req.Info()
|
||||
if err != nil {
|
||||
logger.Error("rent card order err:", err)
|
||||
|
@ -83,6 +89,11 @@ func CooperativeRentCardOrderDeliver(c *gin.Context) {
|
|||
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.StoreId = uint32(assistant.StoreId)
|
||||
err, _ := req.Deliver()
|
||||
|
@ -109,6 +120,12 @@ func CooperativeRentCardOrderRevert(c *gin.Context) {
|
|||
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.OperationUid = uc.Uid
|
||||
err := req.Revert()
|
||||
if err != nil {
|
||||
|
|
|
@ -989,6 +989,12 @@ func InviteMemberReportList(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
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()
|
||||
if err != nil {
|
||||
logger.Errorf("err:", err)
|
||||
|
|
|
@ -131,3 +131,70 @@ func getParam(company, num string) (string, error) {
|
|||
}
|
||||
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"
|
||||
totalFee := uint32(100)
|
||||
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 {
|
||||
fmt.Println("err:", err)
|
||||
|
||||
|
@ -46,5 +46,5 @@ func TestWebPay(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"` // 白金会员数量
|
||||
BlackGoldCount uint32 `json:"black_gold_count"` // 黑金会员数量
|
||||
DayTime string `json:"day_time" gorm:"index"` //
|
||||
//
|
||||
|
||||
// cooperative_member_promotion_store_day
|
||||
}
|
||||
|
||||
// gen:qs
|
||||
|
@ -147,6 +148,10 @@ func AddCooperativeMemberPromotion(cooperativeId, storeId, assistantUid uint32,
|
|||
logger.Error("cooperative business err:", err)
|
||||
return
|
||||
}
|
||||
//fmt.Println("cooperativeId:", cooperativeId)
|
||||
//fmt.Println("storeId:", storeId)
|
||||
//fmt.Println("assistantUid:", assistantUid)
|
||||
//fmt.Println("memberLevel:", memberLevel)
|
||||
|
||||
go func() {
|
||||
promotion := &CooperativeMemberPromotion{CooperativeBusinessId: cooperativeId, CooperativeName: cooperativeBusiness.Name}
|
||||
|
@ -157,7 +162,7 @@ func AddCooperativeMemberPromotion(cooperativeId, storeId, assistantUid uint32,
|
|||
Uid: assistantUid, StoreId: storeId,
|
||||
}
|
||||
begin := DB.Begin()
|
||||
err := promotion.AddPromotion(begin, memberLevel)
|
||||
err = promotion.AddPromotion(begin, memberLevel)
|
||||
if err != nil {
|
||||
begin.Rollback()
|
||||
logger.Error("promotion add promotion err:", err)
|
||||
|
@ -210,25 +215,28 @@ func (m *CooperativeMemberPromotion) AddPromotion(gdb *gorm.DB, memberLevel int)
|
|||
switch memberLevel {
|
||||
case 2:
|
||||
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
|
||||
case 4:
|
||||
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
|
||||
case 5:
|
||||
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
|
||||
}
|
||||
fmt.Println("邀请会员sql:", sql)
|
||||
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))
|
||||
if err != nil {
|
||||
logger.Error("cooperative member promotion record exist err:", 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 {
|
||||
err = gdb.Exec(sql).Error
|
||||
if err != nil {
|
||||
|
@ -257,22 +265,22 @@ func (m *CooperativeMemberPromotionStore) AddPromotion(gdb *gorm.DB, memberLevel
|
|||
switch memberLevel {
|
||||
case 2:
|
||||
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)
|
||||
m.GoldCount = 1
|
||||
case 4:
|
||||
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)
|
||||
m.PlatinumCount = 1
|
||||
case 5:
|
||||
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)
|
||||
m.BlackGoldCount = 1
|
||||
}
|
||||
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))
|
||||
if err != nil {
|
||||
logger.Error("cooperative member promotion record exist err:", err)
|
||||
|
@ -304,19 +312,19 @@ func (m *CooperativeMemberPromotionDay) AddPromotion(gdb *gorm.DB, memberLevel i
|
|||
switch memberLevel {
|
||||
case 2:
|
||||
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
|
||||
case 4:
|
||||
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
|
||||
case 5:
|
||||
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
|
||||
}
|
||||
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))
|
||||
if err != nil {
|
||||
logger.Error("cooperative member promotion record exist err:", err)
|
||||
|
@ -349,22 +357,22 @@ func (m *CooperativeMemberPromotionStoreDay) AddPromotion(gdb *gorm.DB, memberLe
|
|||
switch memberLevel {
|
||||
case 2:
|
||||
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)
|
||||
m.GoldCount = 1
|
||||
case 4:
|
||||
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)
|
||||
m.PlatinumCount = 1
|
||||
case 5:
|
||||
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)
|
||||
m.BlackGoldCount = 1
|
||||
}
|
||||
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))
|
||||
if err != nil {
|
||||
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 {
|
||||
case 2:
|
||||
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)
|
||||
m.GoldCount = 1
|
||||
case 4:
|
||||
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)
|
||||
m.PlatinumCount = 1
|
||||
case 5:
|
||||
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)
|
||||
m.BlackGoldCount = 1
|
||||
}
|
||||
|
||||
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))
|
||||
if err != nil {
|
||||
logger.Error("cooperative member promotion record exist err:", err)
|
||||
|
|
|
@ -665,8 +665,13 @@ func (m *CooperativeRentCardOrderListReq) List() ([]Order, int, error) {
|
|||
m.PageSize = 10
|
||||
}
|
||||
assistant := GetUserByUid(m.AssistantUid)
|
||||
if m.SerialNumber == "" {
|
||||
m.StoreId = assistant.StoreId
|
||||
qs := NewOrderQuerySet(DB).PayStatusEq(2).StoreIdEq(m.StoreId)
|
||||
}
|
||||
if assistant.UserType != 2 {
|
||||
return orders, 0, errors.New("not assistant")
|
||||
}
|
||||
qs := NewOrderQuerySet(DB).PayStatusEq(2)
|
||||
isDeliver := true
|
||||
if m.SerialNumber != "" {
|
||||
isDeliver = false
|
||||
|
@ -717,7 +722,9 @@ func (m *CooperativeRentCardOrderListReq) List() ([]Order, int, error) {
|
|||
if !m.EndTime.IsZero() {
|
||||
qs = qs.CreatedAtLte(m.EndTime)
|
||||
}
|
||||
|
||||
if m.StoreId != 0 {
|
||||
qs = qs.StoreIdEq(m.StoreId)
|
||||
}
|
||||
count, err := qs.Count()
|
||||
if err != nil {
|
||||
logger.Errorf("err:%#v", err)
|
||||
|
@ -771,12 +778,13 @@ func (m *CooperativeRentCardOrderListReq) List() ([]Order, int, error) {
|
|||
}
|
||||
|
||||
type GameCardGoodsStockAnalysisReq struct {
|
||||
Name string `json:"name"`
|
||||
SortType uint32 `json:"sort_type"` // 1-总库存 2-库存 3-用户持有 4-订单数量
|
||||
SortDirection uint32 `json:"sort_direction"` // 1-升序 2-降序
|
||||
CooperativeBusinessId uint32 `json:"cooperative_business_id"` // 合作商id
|
||||
StoreId uint32 `json:"store_id"`
|
||||
PageNum int `json:"page_num"`
|
||||
PageSize int `json:"page_size"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
type GameCardGoodsStockAnalysisResp struct {
|
||||
List []GameCardGoodsStock `json:"list"`
|
||||
|
@ -812,7 +820,7 @@ func (m *GameCardGoodsStockAnalysisReq) GameCardStockListAnalysis() (*GameCardGo
|
|||
} else if m.SortDirection == 2 {
|
||||
sqlOrder += " ASC"
|
||||
}
|
||||
sqlStore := ""
|
||||
sqlStore := fmt.Sprintf(" AND cooperative_business_id = %d", m.CooperativeBusinessId)
|
||||
if m.StoreId != 0 {
|
||||
sqlStore = fmt.Sprintf(" AND store_id = %d", m.StoreId)
|
||||
}
|
||||
|
@ -824,13 +832,13 @@ func (m *GameCardGoodsStockAnalysisReq) GameCardStockListAnalysis() (*GameCardGo
|
|||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
fmt.Println("--sqlName:", sqlName)
|
||||
//fmt.Println("--sqlName:", sqlName)
|
||||
gameIds := make([]string, 0)
|
||||
for i, _ := range gameCards {
|
||||
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, ","))
|
||||
}
|
||||
|
||||
|
@ -1491,6 +1499,9 @@ func (m *AssistantMemberPromotionReq) List() ([]InviteMemberReport, int, error)
|
|||
|
||||
qs := NewInviteMemberReportQuerySet(DB).CooperativeBusinessIdEq(m.Assistant.CooperativeBusinessId).
|
||||
StoreIdEq(m.StoreId)
|
||||
if m.Date != "" {
|
||||
qs = qs.ReportTimeEq(m.Date)
|
||||
}
|
||||
count, err := qs.Count()
|
||||
if err != nil {
|
||||
logger.Error("err:", err)
|
||||
|
@ -1503,5 +1514,25 @@ func (m *AssistantMemberPromotionReq) List() ([]InviteMemberReport, int, error)
|
|||
return reports, totalPage, err
|
||||
}
|
||||
|
||||
reports = InviteMemberReportListSetUser(reports)
|
||||
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{},
|
||||
&CooperativeMemberDeduct{},
|
||||
&CooperativeAssistantMemberDeduct{},
|
||||
|
||||
&CooperativeMemberPromotion{},
|
||||
&CooperativeMemberPromotionStore{},
|
||||
&CooperativeMemberPromotionDay{},
|
||||
|
@ -1158,3 +1159,9 @@ func TestExportGoodsStock(t *testing.T) {
|
|||
fmt.Println("stock:", stock)
|
||||
|
||||
}
|
||||
|
||||
func TestAddCooperativeMemberPromotion(t *testing.T) {
|
||||
InitTestDB()
|
||||
DB = DBDev
|
||||
AddCooperativeMemberPromotion(4, 20, 68608411, 2)
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/jinzhu/gorm"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"math/rand"
|
||||
"mh-server/kuaidi"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -108,6 +109,7 @@ type OrderCard struct {
|
|||
Order *Order `json:"order" gorm:"-"` // 订单
|
||||
GameCard *GameCard `json:"game_card" gorm:"-"` // 游戏
|
||||
Store *Store `json:"store" gorm:"-"` // 游戏
|
||||
RevertStore *Store `json:"revert_store" gorm:"-"` // 游戏
|
||||
//Status uint8 `json:"status" gorm:"index"` // 1-待领取 2-游玩中 3-已归还 4-未领取
|
||||
//PickupCode string `json:"pickup_code"` // 取货码
|
||||
}
|
||||
|
@ -910,8 +912,10 @@ func (m *CooperativeRentCardOrderReq) Info() (Order, error) {
|
|||
|
||||
func CooperativeOrderCardListSetInfo(list []OrderCard) []OrderCard {
|
||||
ids := make([]uint32, 0, len(list))
|
||||
storeIds := make([]uint32, 0, len(list))
|
||||
for i, _ := range list {
|
||||
ids = append(ids, list[i].GameCardId)
|
||||
storeIds = append(storeIds, uint32(list[i].RevertStoreId))
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return list
|
||||
|
@ -919,10 +923,14 @@ func CooperativeOrderCardListSetInfo(list []OrderCard) []OrderCard {
|
|||
|
||||
cardMap, err := GameCardMap(ids)
|
||||
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
|
||||
}
|
||||
|
||||
for i, _ := range list {
|
||||
gameCard, ok1 := cardMap[list[i].GameCardId]
|
||||
if ok1 {
|
||||
|
@ -930,6 +938,11 @@ func CooperativeOrderCardListSetInfo(list []OrderCard) []OrderCard {
|
|||
list[i].GameCoverImg = gameCard.CoverImg
|
||||
list[i].GamePrice = gameCard.Price
|
||||
}
|
||||
|
||||
revertStore, ok2 := storeMap[uint32(list[i].RevertStoreId)]
|
||||
if ok2 {
|
||||
list[i].RevertStore = &revertStore
|
||||
}
|
||||
}
|
||||
|
||||
return list
|
||||
|
@ -1011,10 +1024,9 @@ type CooperativeRentCardOrderDeliverReq struct {
|
|||
}
|
||||
|
||||
func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
||||
paraMap := make(map[string]interface{}, 0)
|
||||
|
||||
order := new(Order)
|
||||
order.ID = m.OrderId
|
||||
|
||||
err := order.GetById()
|
||||
if err != nil && err != RecordNotFound {
|
||||
logger.Error("err:", err)
|
||||
|
@ -1025,6 +1037,7 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
|||
logger.Error("err:", err)
|
||||
return err, ""
|
||||
}
|
||||
|
||||
if len(m.SerialNumbers) != len(order.OrderCards) || len(m.SerialNumbers) == 0 {
|
||||
logger.Error("发货卡的数量与订单游戏卡数量不一致")
|
||||
return errors.New("发货卡的数量与订单游戏卡数量不一致"), "发货卡的数量与订单游戏卡数量不一致"
|
||||
|
@ -1040,10 +1053,12 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
|||
for i, _ := range order.OrderCards {
|
||||
orderCardMaps[order.OrderCards[i].ID] = order.OrderCards[i]
|
||||
}
|
||||
|
||||
receiptTime := time.Time{}
|
||||
if order.DeliveryType == 1 {
|
||||
receiptTime = time.Now()
|
||||
}
|
||||
|
||||
serialNumberMap := make(map[string]GameCardGoods, 0)
|
||||
var serialGoods []GameCardGoods
|
||||
err = NewGameCardGoodsQuerySet(DB).SerialNumberIn(m.SerialNumbers...).All(&serialGoods)
|
||||
|
@ -1058,11 +1073,11 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
|||
isUpdateOrder := false
|
||||
begin := DB.Begin()
|
||||
for _, serialNumber := range m.SerialNumbers {
|
||||
if serialNumber != "" {
|
||||
if serialNumber == "" {
|
||||
continue
|
||||
}
|
||||
paraMap["game_card_serial_number"] = serialNumber
|
||||
gameCardGoods, ok := serialNumberMap["serialNumber"]
|
||||
|
||||
gameCardGoods, ok := serialNumberMap[serialNumber]
|
||||
if !ok {
|
||||
begin.Rollback()
|
||||
logger.Errorf("游戏编号卡未找到:%s", serialNumber)
|
||||
|
@ -1102,13 +1117,16 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
|||
return errors.New("游戏编号卡不是该门店"), "该门店没有改游戏卡"
|
||||
}
|
||||
|
||||
if uint32(m.StoreId) != orderCard.StoreId {
|
||||
if (m.StoreId) != orderCard.StoreId {
|
||||
begin.Rollback()
|
||||
// 订单锁库存
|
||||
logger.Error("订单门店与发货门店不一致")
|
||||
return errors.New("订单门店与发货门店不一致"), "订单门店与发货门店不一致,请取消订单后重新下单"
|
||||
}
|
||||
|
||||
paraMap := make(map[string]interface{}, 0)
|
||||
//paraMap["game_card_serial_number"] = serialNumber
|
||||
|
||||
if !isUpdateOrder {
|
||||
if m.StoreId != 0 {
|
||||
paraMap["store_id"] = m.StoreId
|
||||
|
@ -1126,7 +1144,7 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
|||
if 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 {
|
||||
begin.Rollback()
|
||||
logger.Error("err:", err)
|
||||
|
@ -1137,7 +1155,7 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
|||
|
||||
var eg errgroup.Group
|
||||
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
|
||||
if err != nil {
|
||||
begin.Rollback()
|
||||
|
@ -1173,7 +1191,7 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
|||
return nil
|
||||
})
|
||||
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,
|
||||
"delivery_time": time.Now(),
|
||||
"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
|
||||
if err != nil {
|
||||
begin.Rollback()
|
||||
|
@ -1209,17 +1223,26 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
|||
return err, ""
|
||||
}
|
||||
|
||||
// TODO
|
||||
//if m.ExpressCompanyNo != "" && m.ExpressNo != "" {
|
||||
// _, err = kuaidi.SubscribeExpressState(m.ExpressCompanyNo, m.ExpressNo)
|
||||
// if err != nil {
|
||||
// logger.Error("subscribe express state err:", err)
|
||||
// }
|
||||
//}
|
||||
err = DB.Table("order_card").Where("order_id=?", m.OrderId).Where("uid=?", order.Uid).
|
||||
Where("serial_number=''").Updates(&map[string]interface{}{
|
||||
"card_status": 5,
|
||||
}).Error
|
||||
if err != nil {
|
||||
logger.Error("err:", err)
|
||||
return err, ""
|
||||
}
|
||||
|
||||
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: "借卡归还入库",
|
||||
Description: "借卡发货",
|
||||
OperationType: OperationTypeRentCardDeliver,
|
||||
CorrelationId: order.ID,
|
||||
CorrelationName: LogCorrelationOrderId,
|
||||
|
@ -1229,6 +1252,7 @@ func (m *CooperativeRentCardOrderDeliverReq) Deliver() (error, string) {
|
|||
//SerialNumber: m.SerialNumber,
|
||||
}
|
||||
operationLog.AddLog()
|
||||
}()
|
||||
|
||||
return nil, ""
|
||||
}
|
||||
|
@ -1336,8 +1360,8 @@ func (m *CooperativeRentCardOrderRevertReq) Revert() error {
|
|||
}
|
||||
|
||||
var count int64
|
||||
err := DB.Table("game_card_goods_stock").Where("store_id", m.RevertStoreId).
|
||||
Where("game_card_id", gameCardGoods.GameCardId).Count(&count).Error
|
||||
err := DB.Table("game_card_goods_stock").Where("store_id=?", m.RevertStoreId).
|
||||
Where("game_card_id=?", gameCardGoods.GameCardId).Count(&count).Error
|
||||
if err != nil {
|
||||
begin.Rollback()
|
||||
logger.Error("err:", err)
|
||||
|
@ -1410,7 +1434,7 @@ func (m *CooperativeRentCardOrderRevertReq) Revert() error {
|
|||
return nil
|
||||
})
|
||||
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,
|
||||
"revert_store_id": m.RevertStoreId,
|
||||
"revert_time": time.Now(),
|
||||
|
@ -1429,7 +1453,7 @@ func (m *CooperativeRentCardOrderRevertReq) Revert() error {
|
|||
return err
|
||||
}
|
||||
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,
|
||||
}).Error
|
||||
if err != nil {
|
||||
|
@ -1441,7 +1465,9 @@ func (m *CooperativeRentCardOrderRevertReq) Revert() error {
|
|||
return nil
|
||||
})
|
||||
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)
|
||||
fmt.Println("sql:", sql)
|
||||
err = begin.Exec(sql).Error
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/codinl/go-logger"
|
||||
"golang.org/x/sync/errgroup"
|
||||
"time"
|
||||
|
@ -54,7 +53,7 @@ func GetStoreList(cardInfos []CardInfo) ([]GameCardStock, error) {
|
|||
|
||||
if len(cardInfos) == 0 {
|
||||
stores = *<-storesCh
|
||||
fmt.Println("stores:", stores)
|
||||
//fmt.Println("stores:", stores)
|
||||
for i, _ := range stores {
|
||||
cardStock := GameCardStock{
|
||||
Store: stores[i],
|
||||
|
@ -126,7 +125,7 @@ func GetStoreList(cardInfos []CardInfo) ([]GameCardStock, error) {
|
|||
// list = append(list, cardStock)
|
||||
//}
|
||||
}
|
||||
fmt.Println("list:", list)
|
||||
//fmt.Println("list:", list)
|
||||
return list, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ type User struct {
|
|||
StoreType uint32 `json:"store_type"` // 1-订单门店
|
||||
CooperativeBusinessId uint32 `json:"cooperative_business_id" gorm:"index"` // 合作商id
|
||||
CooperativeName string `json:"cooperative_name"` // 合作商名称
|
||||
ShopAssistantName string `json:"shop_assistant_name"` // 店员名称
|
||||
Version uint32 `json:"-"`
|
||||
UserVm *UserVm `json:"user_vm" gorm:"-"` //
|
||||
//RoleId uint32 `json:"role_id"` // 角色id
|
||||
|
@ -270,6 +271,7 @@ const (
|
|||
const (
|
||||
OperationTypeRentCardRevert = "rent_card_revert"
|
||||
OperationTypeRentCardDeliver = "rent_card_deliver"
|
||||
OperationTypeGameCardGoodsInStock = "game_card_goods_in_stock" // 入库
|
||||
)
|
||||
|
||||
// gen:qs
|
||||
|
@ -283,7 +285,10 @@ type OperationLog struct {
|
|||
StoreId uint32 `json:"store_id" gorm:"index"` // 门店id
|
||||
StoreName string `json:"store_name"` // 门店名称
|
||||
CooperativeName string `json:"cooperative_name"` // 合作商名称
|
||||
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 {
|
||||
|
@ -321,6 +326,7 @@ type InviteMemberReport struct {
|
|||
PlatinumDeduct uint32 `json:"platinum_deduct"` // 白金会员提成
|
||||
BlackGoldDeduct uint32 `json:"black_gold_deduct"` // 黑金会员提成
|
||||
// invite_member_report
|
||||
User *User `json:"user" gorm:"-"`
|
||||
}
|
||||
|
||||
func (m *UserOpenMemberRecord) Refund(outTradeNo string, amount uint32) error {
|
||||
|
@ -896,12 +902,15 @@ func (m *InviteMemberReportListReq) List() ([]InviteMemberReport, int, error) {
|
|||
cooperative := new(CooperativeBusiness)
|
||||
cooperative.ID = assistant.CooperativeBusinessId
|
||||
cooperative.SetAssistantMemberDeductConfig(uint32(assistant.StoreId))
|
||||
fmt.Println("CooperativeBusinessId:", assistant.CooperativeBusinessId, assistant.StoreId)
|
||||
fmt.Println("CooperativeAssistantMemberDeduct:", cooperative.CooperativeAssistantMemberDeduct)
|
||||
if len(memberReport) > 0 {
|
||||
memberReport[len(memberReport)-1].GoldDeduct = cooperative.CooperativeAssistantMemberDeduct.GoldDeduct
|
||||
memberReport[len(memberReport)-1].PlatinumDeduct = cooperative.CooperativeAssistantMemberDeduct.PlatinumDeduct
|
||||
memberReport[len(memberReport)-1].BlackGoldDeduct = cooperative.CooperativeAssistantMemberDeduct.BlackGoldDeduct
|
||||
|
||||
report := memberReport[len(memberReport)-1]
|
||||
fmt.Println("report:", report)
|
||||
memberReport[len(memberReport)-1].DeductAmount += report.GoldCount * report.GoldDeduct
|
||||
memberReport[len(memberReport)-1].DeductAmount += report.PlatinumCount * report.PlatinumDeduct
|
||||
memberReport[len(memberReport)-1].DeductAmount += report.BlackGoldCount * report.BlackGoldDeduct
|
||||
|
@ -909,3 +918,17 @@ func (m *InviteMemberReportListReq) List() ([]InviteMemberReport, int, error) {
|
|||
|
||||
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