相关条件的统计
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

948 lines
37 KiB

  1. package zyos_go_condition_hdl
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/db"
  4. "code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/db/model"
  5. "code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/md"
  6. "code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/svc"
  7. zhios_condition_statistics_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/utils"
  8. "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles"
  9. "encoding/json"
  10. "errors"
  11. "fmt"
  12. "time"
  13. "xorm.io/xorm"
  14. )
  15. func CommUpdate(params map[string]string, blockStarChain string, eg *xorm.Engine, dbName string, user *model.User, DataDetail md.DataDetail) (error, bool, int) {
  16. uid := DataDetail.Uid
  17. //判断有没有审核通过或审核中的记录
  18. has, err := db.UserLevelAuditingFindByUid(eg, zhios_condition_statistics_utils.StrToInt(uid))
  19. if err != nil {
  20. return err, false, 0
  21. }
  22. if has != nil {
  23. var msg = "您已审核通过,请勿重复申请"
  24. if has.State == 1 {
  25. msg = "正在审核中,请稍后再查看"
  26. }
  27. return errors.New(msg), false, 0
  28. }
  29. lv := user.Level
  30. result, AutoAudit := CommUplv(params, blockStarChain, eg, dbName, user, lv, DataDetail)
  31. if result == false {
  32. return errors.New("升级失败,请查看任务是否完成"), false, AutoAudit
  33. }
  34. return nil, result, AutoAudit
  35. }
  36. func CommUplv(params map[string]string, blockStarChain string, eg *xorm.Engine, dbName string, user *model.User, lv int, DataDetail md.DataDetail) (bool, int) {
  37. levelExpireAt := user.LevelExpireAt
  38. levelArriveAt := user.LevelArriveAt
  39. oldLevel := user.Level
  40. uid := zhios_condition_statistics_utils.IntToStr(user.Uid)
  41. result, _, payOrdId := IsCompleteSchemeTask(params, blockStarChain, eg, user, DataDetail.AgentType, DataDetail.IsChangeTime, dbName)
  42. AutoAudit := 0
  43. if result {
  44. level, err := db.UserLevelByID(eg, zhios_condition_statistics_utils.StrToInt(DataDetail.AgentType))
  45. if err != nil || level == nil {
  46. return false, 0
  47. }
  48. date := time.Now()
  49. var auditData = model.UserLevelAudit{
  50. Uid: zhios_condition_statistics_utils.StrToInt(uid),
  51. CurrentLevelId: lv,
  52. NextLevelId: zhios_condition_statistics_utils.StrToInt(DataDetail.AgentType),
  53. ConditionType: 2,
  54. AutoAudit: level.AutoAudit,
  55. DateType: 5,
  56. State: 1,
  57. RelateOid: payOrdId,
  58. CreateAt: date,
  59. UpdateAt: date,
  60. LevelDate: level.LevelDate,
  61. }
  62. has, err := db.UserLevelAuditInsertWithEngine(eg, &auditData)
  63. if has == 0 || err != nil {
  64. return false, 0
  65. }
  66. //自动审核
  67. if level.AutoAudit == 1 {
  68. //写入日志
  69. var log = &model.UserLevelChangeLog{
  70. Uid: user.Uid,
  71. BeforeLv: oldLevel,
  72. AfterLv: zhios_condition_statistics_utils.StrToInt(DataDetail.AgentType),
  73. Time: int(time.Now().Unix()),
  74. BeforeLevelExpireAt: levelExpireAt,
  75. AfterLevelExpireAt: user.LevelExpireAt,
  76. BeforeLevelArriveAt: levelArriveAt,
  77. AfterLevelArriveAt: user.LevelArriveAt,
  78. Type: "level_up",
  79. }
  80. fmt.Println(log)
  81. eg.InsertOne(log)
  82. auditData.State = 2
  83. //审核记录修改
  84. if _, err := db.UserLevelAuditUpdateById(eg, auditData.Id, &auditData, "state"); err != nil {
  85. return false, 0
  86. }
  87. t := time.Now()
  88. var expire time.Time
  89. //订单时间修改
  90. if payOrdId > 0 {
  91. ord, err := db.UserLevelOrderById(eg, zhios_condition_statistics_utils.Int64ToStr(payOrdId))
  92. if err != nil {
  93. return false, 0
  94. }
  95. //过期时间在当前时间之前 并且 创建时间跟过期时间不相等 相等的话是永久会员
  96. if ord.ExpireAt.Unix() < t.Unix() && ord.CreateAt.Format("2006-01-02 15:04:05") != ord.ExpireAt.Format("2006-01-02 15:04:05") && ord.DateType != 4 {
  97. return false, 0
  98. }
  99. switch ord.DateType {
  100. case 1:
  101. // 月
  102. expire = t.AddDate(0, 1, 0)
  103. ord.ExpireAt = expire
  104. case 2:
  105. // 季
  106. expire = t.AddDate(0, 3, 0)
  107. ord.ExpireAt = expire
  108. case 3:
  109. // 年
  110. expire = t.AddDate(1, 0, 0)
  111. ord.ExpireAt = expire
  112. case 4:
  113. expire = t
  114. // 永久(设置为与创建时间相同)
  115. ord.ExpireAt = t
  116. }
  117. if _, err := db.UserLevelOrdUpdateOne(eg, ord); err != nil {
  118. return false, 0
  119. }
  120. }
  121. user.Level = zhios_condition_statistics_utils.StrToInt(DataDetail.AgentType)
  122. user.LevelArriveAt = t
  123. if user.FirstArriveAt.IsZero() {
  124. user.FirstArriveAt = t
  125. }
  126. if payOrdId > 0 {
  127. user.LevelExpireAt = expire
  128. } else {
  129. if level.LevelDate == 0 { // 永久
  130. user.LevelExpireAt = t
  131. } else {
  132. user.LevelExpireAt = t.AddDate(0, level.LevelDate, 0)
  133. }
  134. }
  135. //用户等级修改
  136. // 更新user level 和 过期时间
  137. if _, err := db.UserUpdate(eg, user.Uid, user, "level,level_expire_at,level_arrive_at,first_arrive_at"); err != nil {
  138. return false, 0
  139. }
  140. //升级奖励定制
  141. UpgradeReward(eg, user, zhios_condition_statistics_utils.Int64ToStr(payOrdId))
  142. eg.Where("uid=?", user.Uid).Cols("date").Update(&model.OneCirclesUserLvTime{Date: time.Now()})
  143. AutoAudit = 1
  144. var task model.UserLevelUpgradeTask
  145. eg.Where("scheme_id=? and task_type=22", DataDetail.AgentType).Get(&task)
  146. if task.Id > 0 {
  147. eg.Where("uid=?", user.Uid).Cols("is_not_down").Update(&model.User{IsNotDown: 0})
  148. } else {
  149. eg.Where("uid=?", user.Uid).Cols("is_not_down").Update(&model.User{IsNotDown: 1})
  150. }
  151. }
  152. }
  153. return result, AutoAudit
  154. }
  155. func UpgradeReward(eg *xorm.Engine, user *model.User, oid string) {
  156. buyCouponLvReward, _ := db.SysCfgGetOne(eg, "buy_coupon_lv_reward")
  157. if buyCouponLvReward == nil {
  158. return
  159. }
  160. var args = make([]md.BuyCouponLvRewardList, 0)
  161. json.Unmarshal([]byte(buyCouponLvReward.Val), &args)
  162. for _, v := range args {
  163. if zhios_condition_statistics_utils.StrToInt(v.Id) != user.Level || len(v.Reward) == 0 {
  164. continue
  165. }
  166. for _, v1 := range v.Reward {
  167. if zhios_condition_statistics_utils.StrToFloat64(v1.Amount) <= 0 {
  168. continue
  169. }
  170. if v1.Id == "-1" { //优惠券额度
  171. svc.AddCouponRecord(eg, user, "ordinary", v1.Amount)
  172. }
  173. if zhios_condition_statistics_utils.StrToInt(v1.Id) > 0 {
  174. svc.AddCoin(eg, zhios_condition_statistics_utils.StrToFloat64(v1.Amount), "升级赠送", oid, 1, 188, user.Uid, zhios_condition_statistics_utils.StrToInt(v1.Id))
  175. }
  176. }
  177. }
  178. }
  179. // IsCompleteSchemeTask 根据传入的 level 判断是否可以升级
  180. func IsCompleteSchemeTask(params map[string]string, blockStarChain string, engine *xorm.Engine, user *model.User, level, IsChangeTime, dbName string) (bool, bool, int64) {
  181. uid := zhios_condition_statistics_utils.IntToStr(user.Uid)
  182. userLevel, err := db.UserLevelByID(engine, user.Level)
  183. if err != nil {
  184. return false, false, 0
  185. }
  186. becomeLevel, err := db.UserLevelByID(engine, level)
  187. if err != nil {
  188. return false, false, 0
  189. }
  190. if userLevel == nil {
  191. if level == "" {
  192. level = "1"
  193. }
  194. } else {
  195. if becomeLevel.LevelWeight <= userLevel.LevelWeight && IsChangeTime != "1" {
  196. return false, false, 0
  197. }
  198. }
  199. //获取用户等级方案内容
  200. schemeTasks, err := db.BatchSelectUserLevelUpgradeTasks(engine, map[string]interface{}{
  201. "key": "scheme_id",
  202. "value": becomeLevel.Id,
  203. })
  204. if err != nil {
  205. return false, false, 0
  206. }
  207. return CheckSchemeTasksComplete(params, blockStarChain, engine, schemeTasks, uid, becomeLevel, level, "", dbName)
  208. }
  209. func CheckSchemeTasksComplete(params map[string]string, blockStarChain string, engine *xorm.Engine, tasks *[]model.UserLevelUpgradeTask, uid interface{}, scheme *model.UserLevel, level string, regionalId, dbName string) (bool, bool, int64) {
  210. //分离出 必做/选做 途径(任务组) && 分离出 必做/选做
  211. var tasksGroup []map[string]interface{}
  212. mustTasks := make(map[string][]interface{})
  213. selectTasks := make(map[string][]interface{})
  214. var (
  215. hasLevelPay = false
  216. LevelPayOrdId int64
  217. )
  218. allLvMap := db.UserLevelByAllMap(engine)
  219. for _, item := range *tasks {
  220. var temp = map[string]interface{}{}
  221. temp["id"] = item.Id
  222. temp["pid"] = item.Pid
  223. temp["schemeId"] = item.SchemeId
  224. temp["isMustTask"] = item.IsMustTask
  225. temp["taskType"] = item.TaskType
  226. temp["taskTypeLevelId"] = item.TaskTypeLevelId
  227. temp["withinDays"] = item.WithinDays
  228. temp["finishCount"] = item.FinishCount
  229. temp["payLevels"] = item.PayLevels
  230. temp["finish_task_num"] = item.FinishTaskNum
  231. if item.Pid == 0 && item.IsMustTask == 1 {
  232. temp["is_must"] = "1"
  233. tasksGroup = append(tasksGroup, temp)
  234. }
  235. if item.Pid == 0 && item.IsMustTask != 1 {
  236. temp["is_must"] = "0"
  237. tasksGroup = append(tasksGroup, temp)
  238. }
  239. name := GetTaskName(item.TaskType)
  240. finish, hasPay, payOrdId := GetFinishCount(params, blockStarChain, engine, uid, &item, level, regionalId, allLvMap, dbName)
  241. total := "" // 总共需完成的数
  242. if item.TaskType == 6 {
  243. // 当是付费条件是否,total的指标只能是1
  244. total = "1"
  245. hasLevelPay = hasPay
  246. LevelPayOrdId = payOrdId
  247. } else {
  248. total = item.FinishCount
  249. }
  250. if item.TaskType == 19 {
  251. total = zhios_condition_statistics_utils.IntToStr(zhios_condition_statistics_utils.StrToInt(total) + 1)
  252. }
  253. temp["name"] = name
  254. temp["total"] = total //需完成数
  255. temp["finish"] = finish //已完成数
  256. //fmt.Println("finish:::::::::::::", finish)
  257. //fmt.Println("total:::::::::::::", total)
  258. if zhios_condition_statistics_utils.AnyToFloat64(finish) >= zhios_condition_statistics_utils.AnyToFloat64(total) {
  259. temp["result"] = "1"
  260. } else {
  261. temp["result"] = "0"
  262. }
  263. if item.Pid != 0 && item.IsMustTask == 1 {
  264. mustTasks[zhios_condition_statistics_utils.AnyToString(item.Pid)] = append(mustTasks[zhios_condition_statistics_utils.AnyToString(item.Pid)], temp)
  265. }
  266. if item.Pid != 0 && item.IsMustTask == 0 {
  267. selectTasks[zhios_condition_statistics_utils.AnyToString(item.Pid)] = append(selectTasks[zhios_condition_statistics_utils.AnyToString(item.Pid)], temp)
  268. }
  269. }
  270. alreadyCompleteTasksGroup := 0 // 完成“选做途径”数量
  271. for _, v := range tasksGroup {
  272. fmt.Println(">>>>>>>>>>>>>>>>>>>>", v)
  273. if v["finish_task_num"] == nil {
  274. v["finishCount"] = 0
  275. }
  276. //处理必做途径
  277. if zhios_condition_statistics_utils.AnyToString(v["isMustTask"]) == "1" {
  278. if mustTasks[zhios_condition_statistics_utils.AnyToString(v["id"])] != nil {
  279. needFinishTaskNum := v["finish_task_num"] // 需完成选做任务数
  280. alreadyFinishTaskNum := 0 // 已完成选做任务数
  281. for _, vv := range mustTasks[zhios_condition_statistics_utils.AnyToString(v["id"])] {
  282. tmp := vv.(map[string]interface{})
  283. // 必做任务 且 未完成
  284. if tmp["isMustTask"] == 1 && tmp["result"] != "1" {
  285. return false, hasLevelPay, LevelPayOrdId
  286. }
  287. // 非必做任务 且 已完成
  288. if tmp["isMustTask"] != 1 && tmp["result"] == "1" {
  289. alreadyFinishTaskNum++
  290. }
  291. }
  292. // 需完成选做任务数 大于 已完成选做任务数
  293. if zhios_condition_statistics_utils.AnyToInt64(needFinishTaskNum) > zhios_condition_statistics_utils.AnyToInt64(alreadyFinishTaskNum) {
  294. return false, hasLevelPay, LevelPayOrdId
  295. }
  296. }
  297. }
  298. //处理选做途径
  299. if selectTasks[zhios_condition_statistics_utils.AnyToString(v["id"])] != nil {
  300. needFinishTaskNum := v["finish_task_num"] // 需完成选做任务数
  301. alreadyFinishTaskNum := 0 // 已完成选做任务数
  302. alreadyFinishMustTask := true // 是否已完成必做任务
  303. for _, vv := range selectTasks[zhios_condition_statistics_utils.AnyToString(v["id"])] {
  304. tmp := vv.(map[string]interface{})
  305. // 非必做任务 且 已完成
  306. if tmp["isMustTask"] != "1" && tmp["result"] == "1" {
  307. alreadyFinishTaskNum++
  308. }
  309. // 必做任务 且 未完成
  310. if tmp["isMustTask"] == "1" && tmp["result"] != "1" {
  311. alreadyFinishMustTask = false
  312. }
  313. }
  314. // 已完成必做任务 且 需完成选做任务数 小于等于 已完成选做任务数
  315. if alreadyFinishMustTask && zhios_condition_statistics_utils.AnyToInt64(needFinishTaskNum) <= zhios_condition_statistics_utils.AnyToInt64(alreadyFinishTaskNum) {
  316. alreadyCompleteTasksGroup++
  317. }
  318. }
  319. }
  320. //方案中设定的 需完成“选做途径”数 与 实际完成“选做途径”数 比较
  321. if scheme.ChoosableNum > alreadyCompleteTasksGroup {
  322. return false, hasLevelPay, LevelPayOrdId
  323. }
  324. return true, hasLevelPay, LevelPayOrdId
  325. }
  326. // GetTaskName is 获取任务名
  327. func GetTaskName(id int) string {
  328. switch id {
  329. case 1:
  330. return "累计自购订单总数"
  331. case 2:
  332. return "累计到账佣金"
  333. case 3:
  334. return "累计直推粉丝数量"
  335. case 4:
  336. return "累计团队有效直推人数"
  337. case 5:
  338. return "累计团队符合相应等级的人数"
  339. case 11:
  340. return "累计直推符合相应等级的人数"
  341. case 6:
  342. return "月付价格"
  343. case 7:
  344. return "季付价格"
  345. case 8:
  346. return "年付价格"
  347. case 9:
  348. return "永久价格"
  349. case 10:
  350. return "累计自购消费金额"
  351. case 12:
  352. return "累计团队消费金额"
  353. case 13:
  354. return "累计小市场团队符合等级人数"
  355. case 15:
  356. return "直推前N个店铺营业额"
  357. case 17:
  358. return "团队N条线中各有N个相应等级用户"
  359. case 18:
  360. return "小区累计自营消费金额"
  361. case 20:
  362. return "累计收益(结算)"
  363. case 22:
  364. return "连续活跃"
  365. default:
  366. return "无效名称"
  367. }
  368. }
  369. //
  370. // GetFinishCount is 计算规定时间内完成的指标的数量
  371. func GetFinishCount(params map[string]string, blockStarChain string, engine *xorm.Engine, uid interface{}, task *model.UserLevelUpgradeTask, level string, regionalId string, allLvMap map[int]*model.UserLevel, dbName string) (string, bool, int64) {
  372. t := time.Now()
  373. hasPay := false
  374. var payOrdId int64
  375. switch task.TaskType {
  376. case 20:
  377. var money float64 = 0
  378. shownewFinTotal, _ := db.SysCfgGetOne(engine, "shownew_fin_total2")
  379. if shownewFinTotal != nil && shownewFinTotal.Val == "1" {
  380. var userStatistics model.UserStatistics
  381. engine.Where("uid=?", uid).Get(&userStatistics)
  382. money = zhios_condition_statistics_utils.StrToFloat64(userStatistics.ImportFinTotal) + zhios_condition_statistics_utils.StrToFloat64(userStatistics.FinTotal)
  383. } else {
  384. sumWhere := engine.Where("type=0 and uid=?", uid)
  385. mallSumWhere := engine.Where("uid=? AND type=? and ord_title=?", uid, 1, "订单退款")
  386. deSum2Where := engine.Where("uid=? AND type=? and ord_type=?", uid, 0, "withdraw")
  387. deSum3Where := engine.Where("uid=? AND type=? and ord_title like ?", uid, 1, "%扣除%")
  388. stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location())
  389. etime := t
  390. if task.WithinDays > 0 {
  391. sqlStr4 := fmt.Sprintf(" %s >'%s' AND %s < '%s'", "create_at", stime.Format("2006-01-02 15:04:05"), "create_at", etime.Format("2006-01-02 15:04:05"))
  392. sumWhere = sumWhere.And(sqlStr4)
  393. mallSumWhere = mallSumWhere.And(sqlStr4)
  394. deSum2Where = deSum2Where.And(sqlStr4)
  395. deSum3Where = deSum3Where.And(sqlStr4)
  396. }
  397. sum, _ := sumWhere.Sum(&model.FinUserFlow{}, "amount")
  398. mallSum, _ := mallSumWhere.Sum(&model.FinUserFlow{}, "amount")
  399. deSum2, _ := deSum2Where.Sum(&model.FinUserFlow{}, "amount")
  400. deSum3, _ := deSum3Where.Sum(&model.FinUserFlow{}, "amount")
  401. dsCheck, _ := db.SysCfgGetOne(engine, "ds_check")
  402. money = sum - deSum2 - deSum3 + mallSum
  403. if dsCheck != nil && dsCheck.Val == "1" {
  404. sess := engine.Where("uid=? ", uid).In("state", []string{"1", "2"})
  405. where1 := ""
  406. if task.WithinDays > 0 {
  407. sqlStr4 := fmt.Sprintf(" %s >'%s' AND %s < '%s'", "create_at", stime.Format("2006-01-02 15:04:05"), "create_at", etime.Format("2006-01-02 15:04:05"))
  408. where1 = fmt.Sprintf("AND %s >'%d' AND %s < '%d'", "ol.create_at", stime.Unix(), "ol.create_at", etime.Unix())
  409. sess = sess.And(sqlStr4)
  410. }
  411. withdrawingSuccess, _ := sess.Sum(&model.FinWithdrawApply{}, "amount")
  412. sql := "SELECT cast(SUM(LEFT(olr.amount,LENGTH(olr.amount)-2)) as decimal(50,4)) AS amount FROM ord_list_relate olr JOIN ord_list ol ON olr.oid = ol.ord_id WHERE olr.level=0 and olr.uid = " + zhios_condition_statistics_utils.AnyToString(uid) + " " + where1 + " AND ol.state IN (0,1,2,3) and ol.is_transfer=1;"
  413. nativeString, _ := db.QueryNativeString(engine, sql)
  414. money = withdrawingSuccess
  415. for _, v := range nativeString {
  416. money += zhios_condition_statistics_utils.StrToFloat64(v["amount"])
  417. }
  418. }
  419. }
  420. return zhios_condition_statistics_utils.Float64ToStr(money), hasPay, payOrdId
  421. case 22:
  422. lvTime := db.GetOneCirclesUserLvTime(engine, uid)
  423. stime := time.Date(t.Year(), t.Month(), t.Day()-1, 0, 0, 0, 0, t.Location()).Format("2006-01-02")
  424. if lvTime != nil && lvTime.Date.IsZero() == false {
  425. stime = lvTime.Date.Format("2006-01-02")
  426. }
  427. etime := t.Format("2006-01-02")
  428. if params["is_view"] == "1" {
  429. if lvTime == nil || (lvTime != nil && lvTime.Date.IsZero()) {
  430. stime = t.Format("2006-01-02")
  431. }
  432. etime = time.Date(t.Year(), t.Month(), t.Day()+1, 0, 0, 0, 0, t.Location()).Format("2006-01-02")
  433. }
  434. _, days, activity := one_circles.CalcUserContinuousDailyActivityDays(engine, dbName, int(zhios_condition_statistics_utils.AnyToInt64(uid)), stime, etime)
  435. if activity == false {
  436. days = 0
  437. }
  438. return zhios_condition_statistics_utils.IntToStr(days), hasPay, payOrdId
  439. case 23:
  440. // 累计新人免单自购数
  441. total, err := db.OrderListCountByUIDByOrderTypeByTimeNew(engine, uid, "free", task)
  442. if err != nil {
  443. return "", hasPay, payOrdId
  444. }
  445. return zhios_condition_statistics_utils.Int64ToStr(total), hasPay, payOrdId
  446. case 24:
  447. // 累计自购消费金额
  448. var total float64 = 0
  449. var err error
  450. if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "1"}) {
  451. total, err = db.OrderListSumByUIDByOrderTypeByTimeNew(engine, uid, "free", task)
  452. if err != nil {
  453. return "", hasPay, payOrdId
  454. }
  455. }
  456. return zhios_condition_statistics_utils.Float64ToStr(zhios_condition_statistics_utils.FloatFormat(total, 2)), hasPay, payOrdId
  457. case 1:
  458. // 累计自购数
  459. total, err := db.OrderListCountByUIDByOrderTypeByTimeNew(engine, uid, "", task)
  460. if err != nil {
  461. return "", hasPay, payOrdId
  462. }
  463. mallTotal, err := db.MallOrdWithCountNew(engine, uid, task)
  464. if err != nil {
  465. return zhios_condition_statistics_utils.Int64ToStr(total), hasPay, payOrdId
  466. }
  467. total += mallTotal
  468. o2oTotal, err := db.O2oOrdWithCountNew(engine, uid, task)
  469. if err != nil {
  470. return zhios_condition_statistics_utils.Int64ToStr(total), hasPay, payOrdId
  471. }
  472. total += o2oTotal
  473. b2cTotal, err := db.B2cOrdWithCountNew(engine, uid, task)
  474. if err != nil {
  475. return zhios_condition_statistics_utils.Int64ToStr(total), hasPay, payOrdId
  476. }
  477. total += b2cTotal
  478. return zhios_condition_statistics_utils.Int64ToStr(total), hasPay, payOrdId
  479. case 10:
  480. // 累计自购消费金额
  481. var total float64 = 0
  482. var err error
  483. if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "1"}) {
  484. total, err = db.OrderListSumByUIDByOrderTypeByTimeNew(engine, uid, "", task)
  485. if err != nil {
  486. return "", hasPay, payOrdId
  487. }
  488. }
  489. if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "2", "8", "9"}) {
  490. orderType := 0
  491. if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"8", "9"}) {
  492. orderType = task.TaskTypePvd
  493. }
  494. secondTotal, err := db.MallOrdWithSumNew(engine, uid, orderType, task)
  495. if err != nil {
  496. return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId
  497. }
  498. total += secondTotal
  499. }
  500. if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "3"}) {
  501. secondTotal, err := db.O2oOrdWithSumNew(engine, uid, task)
  502. if err != nil {
  503. return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId
  504. }
  505. total += secondTotal
  506. }
  507. if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "4"}) {
  508. secondTotal, err := db.B2cOrdWithSumNew(engine, uid, task)
  509. if err != nil {
  510. return zhios_condition_statistics_utils.Float64ToStr(total), hasPay, payOrdId
  511. }
  512. total += secondTotal
  513. }
  514. return zhios_condition_statistics_utils.Float64ToStr(zhios_condition_statistics_utils.FloatFormat(total, 2)), hasPay, payOrdId
  515. case 2, 25:
  516. // 累计自购佣金
  517. sum, err := db.OrderRelateListByTimeByStateNew(engine, uid, task)
  518. if err != nil {
  519. return "", hasPay, payOrdId
  520. }
  521. mallSum, err := db.MallOrderRelateListByTimeByStateNew(engine, uid, task)
  522. if err != nil {
  523. return zhios_condition_statistics_utils.Float64ToStr(sum), hasPay, payOrdId
  524. }
  525. sum += mallSum
  526. o2oSum, err := db.O2oOrderRelateListByTimeByStateNew(engine, uid, task)
  527. if err != nil {
  528. return zhios_condition_statistics_utils.Float64ToStr(sum), hasPay, payOrdId
  529. }
  530. sum += o2oSum
  531. b2cSum, err := db.B2cOrderRelateListByTimeByStateNew(engine, uid, task)
  532. if err != nil {
  533. return zhios_condition_statistics_utils.Float64ToStr(sum), hasPay, payOrdId
  534. }
  535. sum += b2cSum
  536. return zhios_condition_statistics_utils.Float64ToStr(sum), hasPay, payOrdId
  537. case 3:
  538. // 累计直推人数
  539. stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05")
  540. etime := t.Format("2006-1-02 15:04:05")
  541. sqlTpl := `SELECT count(*) as count
  542. FROM user_relate as up
  543. LEFT JOIN user as u ON u.uid=up.uid
  544. WHERE %s and up.level=1;`
  545. var condStr string
  546. if task.WithinDays <= 0 {
  547. condStr = fmt.Sprintf("up.parent_uid=%s ", zhios_condition_statistics_utils.AnyToString(uid))
  548. } else {
  549. condStr = fmt.Sprintf("up.parent_uid=%s AND u.create_at>'%s' AND u.create_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), stime, etime)
  550. }
  551. sql := fmt.Sprintf(sqlTpl, condStr)
  552. results, err := db.QueryNativeString(engine, sql)
  553. if err != nil {
  554. return "", hasPay, payOrdId
  555. }
  556. count := ""
  557. if len(results) > 0 {
  558. count = zhios_condition_statistics_utils.AnyToString(results[0]["count"])
  559. }
  560. return count, hasPay, payOrdId
  561. case 4:
  562. // 累计团队有效直推人数
  563. stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05")
  564. etime := t.Format("2006-1-02 15:04:05")
  565. sqlTpl := `SELECT count(*) as count
  566. FROM user_relate as up
  567. LEFT JOIN user as u ON u.uid=up.uid
  568. LEFT JOIN user_profile as ups ON up.uid=ups.uid
  569. WHERE %s and up.level=1;`
  570. var condStr string
  571. if task.WithinDays <= 0 {
  572. condStr = fmt.Sprintf("up.parent_uid=%s and ups.is_verify=%d", zhios_condition_statistics_utils.AnyToString(uid), 1)
  573. } else {
  574. condStr = fmt.Sprintf("up.parent_uid=%s AND u.create_at>'%s' AND u.create_at<'%s' and ups.is_verify=%d", zhios_condition_statistics_utils.AnyToString(uid), stime, etime, 1)
  575. }
  576. sql := fmt.Sprintf(sqlTpl, condStr)
  577. results, err := db.QueryNativeString(engine, sql)
  578. if err != nil {
  579. return "", hasPay, payOrdId
  580. }
  581. count := ""
  582. if len(results) > 0 {
  583. count = zhios_condition_statistics_utils.AnyToString(results[0]["count"])
  584. }
  585. return count, hasPay, payOrdId
  586. case 5:
  587. // 累计团队符合相应等级的人数
  588. stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05")
  589. etime := t.Format("2006-1-02 15:04:05")
  590. sqlTpl := `SELECT count(*) as count
  591. FROM user_relate as ur
  592. LEFT JOIN user as u ON u.uid=ur.uid
  593. LEFT JOIN user_level ul on u.level=ul.id
  594. WHERE %s;`
  595. levelList := allLvMap[task.TaskTypeLevelId]
  596. levelWeight := 0
  597. if levelList != nil {
  598. levelWeight = levelList.LevelWeight
  599. }
  600. var condStr string
  601. if task.WithinDays <= 0 {
  602. condStr = fmt.Sprintf("ur.parent_uid=%s AND ul.level_weight>='%s' ", zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight))
  603. if blockStarChain == "1" {
  604. condStr = fmt.Sprintf("ur.parent_uid=%s AND ul.level_weight>='%s' ", zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight))
  605. }
  606. } else {
  607. condStr = fmt.Sprintf("ur.parent_uid=%s AND ul.level_weight>='%s' AND u.create_at>'%s' AND u.create_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
  608. if blockStarChain == "1" {
  609. condStr = fmt.Sprintf("ur.parent_uid=%s AND ul.level_weight>='%s' AND u.level_arrive_at>'%s' AND u.level_arrive_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
  610. }
  611. }
  612. sql := fmt.Sprintf(sqlTpl, condStr)
  613. fmt.Println(sql)
  614. results, err := db.QueryNativeString(engine, sql)
  615. if err != nil {
  616. return "", hasPay, payOrdId
  617. }
  618. count := ""
  619. if len(results) > 0 {
  620. count = zhios_condition_statistics_utils.AnyToString(results[0]["count"])
  621. }
  622. return count, hasPay, payOrdId
  623. case 11:
  624. // 累计直推符合相应等级的人数
  625. stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05")
  626. etime := t.Format("2006-1-02 15:04:05")
  627. sqlTpl := `SELECT count(*) as count
  628. FROM user_relate as ur
  629. LEFT JOIN user as u ON u.uid=ur.uid
  630. LEFT JOIN user_level ul on u.level=ul.id
  631. WHERE %s;`
  632. levelList := allLvMap[task.TaskTypeLevelId]
  633. levelWeight := 0
  634. if levelList != nil {
  635. levelWeight = levelList.LevelWeight
  636. }
  637. var condStr string
  638. if task.WithinDays <= 0 {
  639. condStr = fmt.Sprintf("ur.parent_uid=%s AND ur.level=%s AND ul.level_weight>='%s' ", zhios_condition_statistics_utils.AnyToString(uid), "1", zhios_condition_statistics_utils.IntToStr(levelWeight))
  640. if blockStarChain == "1" {
  641. condStr = fmt.Sprintf("ur.parent_uid=%s AND ur.level=%s AND ul.level_weight>='%s' ", zhios_condition_statistics_utils.AnyToString(uid), "1", zhios_condition_statistics_utils.IntToStr(levelWeight))
  642. }
  643. } else {
  644. condStr = fmt.Sprintf("ur.parent_uid=%s AND ur.level=%s AND ul.level_weight>='%s' AND u.create_at>'%s' AND u.create_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), "1", zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
  645. if blockStarChain == "1" {
  646. condStr = fmt.Sprintf("ur.parent_uid=%s AND ur.level=%s AND ul.level_weight>='%s' AND u.level_arrive_at>'%s' AND u.level_arrive_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), "1", zhios_condition_statistics_utils.IntToStr(levelWeight), stime, etime)
  647. }
  648. }
  649. sql := fmt.Sprintf(sqlTpl, condStr)
  650. fmt.Println(sql)
  651. results, err := db.QueryNativeString(engine, sql)
  652. if err != nil {
  653. return "", hasPay, payOrdId
  654. }
  655. count := ""
  656. if len(results) > 0 {
  657. count = zhios_condition_statistics_utils.AnyToString(results[0]["count"])
  658. }
  659. return count, hasPay, payOrdId
  660. case 21:
  661. // 累计所有下级
  662. stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()).Format("2006-1-02 15:04:05")
  663. etime := t.Format("2006-1-02 15:04:05")
  664. sqlTpl := `SELECT count(*) as count
  665. FROM user_relate as ur
  666. LEFT JOIN user as u ON u.uid=ur.uid
  667. WHERE %s;`
  668. var condStr string
  669. if task.WithinDays <= 0 {
  670. condStr = fmt.Sprintf("ur.parent_uid=%s ", zhios_condition_statistics_utils.AnyToString(uid))
  671. } else {
  672. condStr = fmt.Sprintf("ur.parent_uid=%s AND u.create_at>'%s' AND u.create_at<'%s'", zhios_condition_statistics_utils.AnyToString(uid), stime, etime)
  673. }
  674. sql := fmt.Sprintf(sqlTpl, condStr)
  675. fmt.Println(sql)
  676. results, err := db.QueryNativeString(engine, sql)
  677. if err != nil {
  678. return "", hasPay, payOrdId
  679. }
  680. count := ""
  681. if len(results) > 0 {
  682. count = zhios_condition_statistics_utils.AnyToString(results[0]["count"])
  683. }
  684. return count, hasPay, payOrdId
  685. case 12: //累计团队消费金额
  686. var total float64 = 0
  687. if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "2", "8", "9"}) {
  688. secondTotal, _ := db.MallOrderTeamRelateListByTimeByStateNew(engine, uid, task)
  689. total += secondTotal
  690. }
  691. if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "3"}) {
  692. secondTotal, _ := db.O2oOrderTeamRelateListByTimeByStateNew(engine, uid, task)
  693. total += secondTotal
  694. }
  695. if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "4"}) {
  696. secondTotal, _ := db.B2cOrderTeamRelateListByTimeByStateNew(engine, uid, task)
  697. total += secondTotal
  698. }
  699. if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"0", "1"}) {
  700. secondTotal, _ := db.OrderTeamRelateListByTimeByStateNew(engine, uid, task)
  701. total += secondTotal
  702. }
  703. return zhios_condition_statistics_utils.Float64ToStr(zhios_condition_statistics_utils.FloatFormat(total, 2)), hasPay, payOrdId
  704. case 13:
  705. //小市场团队符合条件人数
  706. smallUid := TotalSmallTeam(engine, zhios_condition_statistics_utils.AnyToString(uid))
  707. sqlTpl := `SELECT count(*) as count
  708. FROM user_relate as ur
  709. LEFT JOIN user as u ON u.uid=ur.uid
  710. WHERE %s;`
  711. condStr := fmt.Sprintf("ur.parent_uid=%s AND u.level='%s' ", smallUid, zhios_condition_statistics_utils.IntToStr(task.TaskTypeLevelId))
  712. sql := fmt.Sprintf(sqlTpl, condStr)
  713. results, err := db.QueryNativeString(engine, sql)
  714. if err != nil {
  715. return "", hasPay, payOrdId
  716. }
  717. count := ""
  718. if len(results) > 0 {
  719. count = zhios_condition_statistics_utils.AnyToString(results[0]["count"])
  720. }
  721. return count, hasPay, payOrdId
  722. case 15:
  723. if task.TaskTypeCount == 0 {
  724. return "0", hasPay, payOrdId
  725. }
  726. //stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()).Format("2006-01-02 15:04:05")
  727. //etime := t.Format("2006-01-02 15:04:05")
  728. if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"1"}) { //o2o
  729. sqlTpl := `SELECT os.id
  730. FROM user_relate ur
  731. LEFT JOIN o2o_merchant om ON ur.uid = om.uid
  732. LEFT JOIN o2o_store os on om.id=os.store_manager
  733. WHERE ur.parent_uid = ?
  734. AND ur.level =1 ORDER BY ur.invite_time asc LIMIT 0,?;
  735. `
  736. var ids = make([]string, 0)
  737. result, err := db.QueryNativeString(engine, sqlTpl, uid, task.TaskTypeCount)
  738. if err == nil {
  739. for _, v := range result {
  740. ids = append(ids, v["id"])
  741. }
  742. }
  743. if len(ids) > 0 {
  744. sum, _ := engine.In("belong_store_id", ids).In("state", []string{"3", "4"}).Sum(&model.O2oOrd{}, "cost_price")
  745. sum1, _ := engine.In("belong_store_id", ids).Sum(&model.O2oPayToMerchant{}, "actual_pay_amount")
  746. return zhios_condition_statistics_utils.Float64ToStrByPrec(sum+sum1, 4), hasPay, payOrdId
  747. }
  748. }
  749. if zhios_condition_statistics_utils.InArr(zhios_condition_statistics_utils.IntToStr(task.TaskTypePvd), []string{"2"}) { //b2c
  750. sqlTpl := `SELECT os.id
  751. FROM user_relate ur
  752. LEFT JOIN o2o_merchant om ON ur.uid = om.uid
  753. LEFT JOIN b2c_ord os on om.id=os.store_manager
  754. WHERE ur.parent_uid = ?
  755. AND ur.level =1 ORDER BY ur.invite_time asc LIMIT 0,?;
  756. `
  757. var ids = make([]string, 0)
  758. result, err := db.QueryNativeString(engine, sqlTpl, uid, task.TaskTypeCount)
  759. if err == nil {
  760. for _, v := range result {
  761. ids = append(ids, v["id"])
  762. }
  763. }
  764. if len(ids) > 0 {
  765. sum, _ := engine.In("belong_store_id", ids).In("state", []string{"4"}).Sum(&model.B2cOrd{}, "cost_price")
  766. return zhios_condition_statistics_utils.Float64ToStrByPrec(sum, 4), hasPay, payOrdId
  767. }
  768. }
  769. return "0", hasPay, payOrdId
  770. case 6:
  771. hasPay = true
  772. //TODO::根据 RegionalAgentSchemeTask 表中的 task_id 判断是否完成付费任务
  773. regionalAgentUserOrd, err := db.UserLevelOrderByTaskId(engine, zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(task.Id))
  774. if err != nil {
  775. return "", hasPay, payOrdId
  776. }
  777. if regionalAgentUserOrd != nil {
  778. if regionalAgentUserOrd.ExpireAt.Unix() < t.Unix() && regionalAgentUserOrd.CreateAt.Format("2006-01-02 15:04:05") != regionalAgentUserOrd.ExpireAt.Format("2006-01-02 15:04:05") && regionalAgentUserOrd.DateType != 4 {
  779. return "0", hasPay, payOrdId
  780. }
  781. payOrdId = regionalAgentUserOrd.Id
  782. return "1", hasPay, payOrdId
  783. } else {
  784. return "0", hasPay, payOrdId
  785. }
  786. return "1", hasPay, payOrdId
  787. case 17:
  788. stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()).Format("2006-01-02 15:04:05")
  789. etime := t.Format("2006-01-02 15:04:05")
  790. // 团队N条线中各有N个相应等级用户
  791. sqlTpl := `select ur.parent_uid,COUNT(*) as count FROM user_relate ur
  792. LEFT JOIN user u on u.uid=ur.uid
  793. LEFT JOIN user_level ul on u.level=ul.id
  794. where ur.parent_uid in(SELECT uid FROM user_relate WHERE parent_uid=%s and level=1 ) and ul.level_weight>=%s %s GROUP BY ur.parent_uid;`
  795. levelList := allLvMap[task.TaskTypeLevelId]
  796. levelWeight := 0
  797. if levelList != nil {
  798. levelWeight = levelList.LevelWeight
  799. }
  800. sql := ""
  801. if task.WithinDays <= 0 {
  802. sql = fmt.Sprintf(sqlTpl, zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), "")
  803. } else {
  804. sql = fmt.Sprintf(sqlTpl, zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), "and u.level_arrive_at>='"+stime+"' and u.level_arrive_at<='"+etime+"'")
  805. }
  806. results, err := db.QueryNativeString(engine, sql)
  807. if err != nil {
  808. return "", hasPay, payOrdId
  809. }
  810. sqlTpl1 := `select ur.uid FROM user_relate ur
  811. LEFT JOIN user u on u.uid=ur.uid
  812. LEFT JOIN user_level ul on u.level=ul.id
  813. where ur.parent_uid=%s and ur.level=1 and ul.level_weight>=%s %s ;`
  814. sql1 := ""
  815. if task.WithinDays <= 0 {
  816. sql1 = fmt.Sprintf(sqlTpl1, zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), "")
  817. } else {
  818. sql1 = fmt.Sprintf(sqlTpl1, zhios_condition_statistics_utils.AnyToString(uid), zhios_condition_statistics_utils.IntToStr(levelWeight), "and u.level_arrive_at>='"+stime+"' and u.level_arrive_at<='"+etime+"'")
  819. }
  820. results1, err1 := db.QueryNativeString(engine, sql1)
  821. if err1 != nil {
  822. return "", hasPay, payOrdId
  823. }
  824. var firstList = make(map[string]string)
  825. if len(results1) > 0 {
  826. for _, v := range results1 {
  827. firstList[v["uid"]] = "1"
  828. }
  829. }
  830. if len(results) > 0 {
  831. for _, v := range results {
  832. firstList[v["parent_uid"]] = zhios_condition_statistics_utils.IntToStr(zhios_condition_statistics_utils.StrToInt(v["count"]) + zhios_condition_statistics_utils.StrToInt(firstList[v["parent_uid"]]))
  833. }
  834. }
  835. count := 0
  836. if len(firstList) > 0 {
  837. for _, v := range firstList {
  838. if zhios_condition_statistics_utils.StrToInt(v) >= task.TaskTypeSecondCount && task.TaskTypeSecondCount > 0 {
  839. count++
  840. }
  841. }
  842. }
  843. return zhios_condition_statistics_utils.IntToStr(count), hasPay, payOrdId
  844. case 18:
  845. stime := time.Date(t.Year(), t.Month(), t.Day()-task.WithinDays, t.Hour(), 0, 0, 0, t.Location()).Format("2006-01-02 15:04:05")
  846. etime := t.Format("2006-01-02 15:04:05")
  847. // 小区消费金额
  848. sqlTpl := `SELECT SUM(molr.goods_price) as price FROM mall_ord_list_relate molr
  849. LEFT JOIN mall_ord mo on mo.ord_id=molr.oid and mo.state in (%s)
  850. WHERE molr.uid in(SELECT uid FROM user_relate WHERE parent_uid=%s and level=1) %s GROUP BY molr.uid ;`
  851. state := "1,2,3"
  852. if task.TaskTypePvd == 1 {
  853. state = "2,3"
  854. }
  855. if task.TaskTypePvd == 2 {
  856. state = "3"
  857. }
  858. sql := ""
  859. if task.WithinDays <= 0 {
  860. sql = fmt.Sprintf(sqlTpl, state, zhios_condition_statistics_utils.AnyToString(uid), "")
  861. } else {
  862. sql = fmt.Sprintf(sqlTpl, state, zhios_condition_statistics_utils.AnyToString(uid), "and mo.create_time>='"+stime+"' and mo.create_time<='"+etime+"'")
  863. }
  864. results, err := db.QueryNativeString(engine, sql)
  865. if err != nil {
  866. return "", hasPay, payOrdId
  867. }
  868. var count float64 = 0
  869. if len(results) > 0 {
  870. var max float64 = 0
  871. for _, v := range results {
  872. if zhios_condition_statistics_utils.StrToFloat64(v["price"]) > max {
  873. max = zhios_condition_statistics_utils.StrToFloat64(v["price"])
  874. }
  875. count += zhios_condition_statistics_utils.StrToFloat64(v["price"])
  876. }
  877. count -= max
  878. }
  879. return zhios_condition_statistics_utils.Float64ToStrByPrec(count, 2), hasPay, payOrdId
  880. case 19:
  881. teamCountMinData, _ := db.SysCfgGetOne(engine, "team_count_min")
  882. teamCountMin := 15
  883. if teamCountMinData != nil {
  884. teamCountMin = zhios_condition_statistics_utils.StrToInt(teamCountMinData.Val)
  885. }
  886. teamtotal := db.GetUserTeamTotal(engine, zhios_condition_statistics_utils.AnyToString(uid))
  887. var count = 0
  888. if teamtotal != nil && teamtotal.FirstCount >= teamCountMin && teamtotal.SecondCount >= teamCountMin {
  889. count++
  890. }
  891. sql := `SELECT * FROM user_profile up
  892. LEFT JOIN user_team_total utt ON utt.uid=up.uid
  893. WHERE up.parent_uid=? and utt.first_count>=? and utt.second_count>=?
  894. `
  895. nativeString, _ := db.QueryNativeString(engine, sql, zhios_condition_statistics_utils.AnyToString(uid), teamCountMin, teamCountMin)
  896. if len(nativeString) > 0 {
  897. count += len(nativeString)
  898. }
  899. return zhios_condition_statistics_utils.IntToStr(count), hasPay, payOrdId
  900. default:
  901. return "", hasPay, payOrdId
  902. }
  903. }