相关条件的统计
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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