附近小店
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

59 строки
2.0 KiB

  1. package hdl
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/svc"
  6. "applet/app/utils"
  7. "fmt"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func StoreIndexTotal(c *gin.Context) {
  11. var arg map[string]string
  12. if err := c.ShouldBindJSON(&arg); err != nil {
  13. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  14. return
  15. }
  16. user := svc.GetUser(c)
  17. stime, etime := svc.GetDate(c, arg)
  18. sql := `select SUM(amount-agent_commission-platform_commission) AS money,SUM(amount) AS amount,SUM(commission) AS commission,SUM(IF(state=3,1,0)) as count,SUM(IF(state in(1,2),1,0)) as success_count,
  19. SUM(IF(state=1,1,0)) as wait_count
  20. from community_team_order
  21. where %s
  22. `
  23. where := "store_uid=" + utils.IntToStr(user.Info.Uid) + " and state>0"
  24. wherePay := where + " and create_at>='" + stime.Format("2006-01-02 15:04:05") + "' and create_at<'" + etime.Format("2006-01-02 15:04:05") + "'"
  25. sqlPay := fmt.Sprintf(sql, wherePay)
  26. nativeString, _ := db.QueryNativeString(svc.MasterDb(c), sqlPay)
  27. amount := "0"
  28. money := "0"
  29. commission := "0"
  30. count := "0"
  31. successCount := "0"
  32. waitCount := "0"
  33. for _, v := range nativeString {
  34. amount = v["amount"]
  35. money = v["money"]
  36. commission = v["commission"]
  37. count = v["count"]
  38. successCount = v["success_count"]
  39. waitCount = v["wait_count"]
  40. }
  41. store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  42. tmp := []map[string]string{
  43. {"name": "营业总额", "value": svc.GetCommissionPrec(c, amount, "2", "1")},
  44. }
  45. if store.StoreType == 0 {
  46. tmp = append(tmp, map[string]string{"name": "佣金收益", "value": svc.GetCommissionPrec(c, commission, "2", "1")})
  47. }
  48. if store.StoreType > 0 {
  49. tmp = append(tmp, map[string]string{"name": "订单收益", "value": svc.GetCommissionPrec(c, money, "2", "1")})
  50. }
  51. tmp = append(tmp, map[string]string{"name": "已付款订单量", "value": successCount})
  52. tmp = append(tmp, map[string]string{"name": "已取消订单量", "value": count})
  53. tmp = append(tmp, map[string]string{"name": "待提货订单量", "value": waitCount})
  54. e.OutSuc(c, tmp, nil)
  55. return
  56. }