huangjiajun 1 anno fa
parent
commit
d36dfb3ac7
1 ha cambiato i file con 38 aggiunte e 0 eliminazioni
  1. +38
    -0
      consume/zhios_appreciation.go

+ 38
- 0
consume/zhios_appreciation.go Vedi File

@@ -92,6 +92,13 @@ func handleZhiosAppreciation(msg []byte) error {
return err
}
}
//类型 购物退回
if canalMsg.Type == "buy_refund" {
err := buyRefund(eg, canalMsg)
if err != nil {
return err
}
}

return nil
}
@@ -238,6 +245,37 @@ func destroy(eg *xorm.Engine, msg *md.ZhiosAppreciation) error {
return nil
}

//购物退回
func buyRefund(eg *xorm.Engine, msg *md.ZhiosAppreciation) error {
args := make(map[string]string)
json.Unmarshal([]byte(msg.Ext), &args)
sess := eg.NewSession()
defer sess.Close()
sess.Begin()
base := db.GetAppreciationBase(sess)
beforeValue := "0"
beforeFlowValue := "0"
if base != nil {
beforeValue = base.Sum
beforeFlowValue = base.FlowSum
}
appreciationCoinId := db.SysCfgGetWithDb(eg, msg.Mid, "appreciation_coin_id")
//转出
err := db.InsertAppreciation(sess, appreciationCoinId, msg.Uid, "5", "0", msg.Oid, args["amount"], args["amount"], beforeValue, beforeFlowValue)
if err != nil {
sess.Rollback()
return err
}

sql := `UPDATE appreciation_base SET sum=sum+?,flow_sum=flow_sum+? WHERE is_use=1;`
_, err = eg.Exec(sql, utils.StrToFloat64(args["amount"]), utils.StrToFloat64(args["amount"]))
if err != nil {
sess.Rollback()
return err
}
sess.Commit()
return nil
}
func caleBili(eg *xorm.Engine, sess *xorm.Session, dbName string, args map[string]string) map[string]string {
appreciationCoinId := db.SysCfgGetWithDb(eg, dbName, "appreciation_coin_id")
bCoinStr := ""


Caricamento…
Annulla
Salva