优惠券额度包
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

coupon_total.go 1.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package zyos_go_coupon
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_coupon.git/db"
  4. "code.fnuoos.com/go_rely_warehouse/zyos_go_coupon.git/db/model"
  5. "xorm.io/xorm"
  6. )
  7. //统计额度
  8. func CouponTotal(eg *xorm.Engine, uid int) (userCouponAmount float64, couponSum float64, buySum float64) {
  9. userCouponAmount = GetCouponAmount(eg, uid, "", "leave_coupon_amount_value") //剩余额度
  10. couponSum = GetCouponAmount(eg, uid, "", "coupon_amount_value") //总额度
  11. buySum = GetCouponOrdAmount(eg, uid, "coupon_amount_value", 2, 4, 6) //购买总额度
  12. return userCouponAmount, couponSum, buySum
  13. }
  14. //购买统计
  15. func GetCouponOrdAmount(eg *xorm.Engine, uid int, cols string, ordType ...int) float64 {
  16. sum, err := db.GetCouponUserOrdBySumWithOrdType(eg, uid, cols, ordType...)
  17. if err != nil {
  18. return 0
  19. }
  20. return sum
  21. }
  22. //额度统计
  23. func GetCouponAmount(eg *xorm.Engine, uid int, pvd string, cols string) float64 {
  24. var data = &model.CommCouponUserTotal{
  25. Uid: uid,
  26. }
  27. if pvd != "" {
  28. data.PvdType = pvd
  29. }
  30. sum, err := db.GetCouponUserTotalByLeaveSum(eg, data, cols)
  31. if err != nil {
  32. return 0
  33. }
  34. return sum
  35. }