|
123456789101112131415161718192021222324252627282930313233343536373839 |
- package zyos_go_coupon
-
- import (
- "code.fnuoos.com/go_rely_warehouse/zyos_go_coupon.git/db"
- "code.fnuoos.com/go_rely_warehouse/zyos_go_coupon.git/db/model"
- "xorm.io/xorm"
- )
-
- //统计额度
- func CouponTotal(eg *xorm.Engine, uid int) (userCouponAmount float64, couponSum float64, buySum float64) {
- userCouponAmount = GetCouponAmount(eg, uid, "", "leave_coupon_amount_value") //剩余额度
- couponSum = GetCouponAmount(eg, uid, "", "coupon_amount_value") //总额度
- buySum = GetCouponOrdAmount(eg, uid, "coupon_amount_value", 2, 4, 6) //购买总额度
- return userCouponAmount, couponSum, buySum
- }
-
- //购买统计
- func GetCouponOrdAmount(eg *xorm.Engine, uid int, cols string, ordType ...int) float64 {
- sum, err := db.GetCouponUserOrdBySumWithOrdType(eg, uid, cols, ordType...)
- if err != nil {
- return 0
- }
- return sum
- }
-
- //额度统计
- func GetCouponAmount(eg *xorm.Engine, uid int, pvd string, cols string) float64 {
- var data = &model.CommCouponUserTotal{
- Uid: uid,
- }
- if pvd != "" {
- data.PvdType = pvd
- }
- sum, err := db.GetCouponUserTotalByLeaveSum(eg, data, cols)
- if err != nil {
- return 0
- }
- return sum
- }
|