优惠券额度包
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

40 líneas
1.1 KiB

  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. }