附近小店
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.
 
 
 

84 line
2.7 KiB

  1. package hdl
  2. import (
  3. "applet/app/db"
  4. "applet/app/db/model"
  5. "applet/app/e"
  6. "applet/app/svc"
  7. "applet/app/utils"
  8. "encoding/json"
  9. "github.com/gin-gonic/gin"
  10. "strings"
  11. "time"
  12. )
  13. func StoreOrderList(c *gin.Context) {
  14. svc.StoreOrderList(c)
  15. }
  16. func StoreOrderCate(c *gin.Context) {
  17. svc.StoreOrderCate(c)
  18. }
  19. func StoreOrderDetail(c *gin.Context) {
  20. svc.StoreOrderDetail(c)
  21. }
  22. func StoreOrderConfirm(c *gin.Context) {
  23. svc.StoreOrderConfirm(c)
  24. }
  25. func GetNewOrderNoticeList(c *gin.Context) {
  26. user := svc.GetUser(c)
  27. storeId := user.Info.Uid
  28. payTipOpen := db.SysCfgGet(c, "community_pay_tip_open")
  29. list := make([]string, 0)
  30. if payTipOpen == "1" {
  31. today := utils.GetTimeRange("today")
  32. todayTime := time.Unix(today["start"], 0).Format("2006-01-02 15:04:05")
  33. sql2 := `select * from community_team_pay_order where is_notice=0 and store_uid=? and state>0 and create_at>=? order by create_at asc`
  34. nativeString2, _ := db.QueryNativeString(svc.MasterDb(c), sql2, storeId, todayTime)
  35. payCodeTip := db.SysCfgGet(c, "community_pay_code_tip")
  36. payGoodsTip := db.SysCfgGet(c, "community_pay_goods_tip")
  37. payGoodsSecondTip := db.SysCfgGet(c, "community_pay_goods_second_tip")
  38. payGoodsTipType := db.SysCfgGet(c, "community_pay_goods_tip_type")
  39. for _, v := range nativeString2 {
  40. payCodeTipStr := strings.ReplaceAll(payCodeTip, "[金额]", svc.GetCommissionPrec(c, v["amount"], "2", "1"))
  41. list = append(list, payCodeTipStr)
  42. svc.MasterDb(c).Where("id=? ", v["id"]).Cols("is_notice").Update(&model.CommunityTeamPayOrder{IsNotice: 1})
  43. }
  44. sql := `select * from community_team_order where is_notice=0 and store_uid=? and state in(1,2) and pay_at>=? order by pay_at asc`
  45. nativeString, _ := db.QueryNativeString(svc.MasterDb(c), sql, storeId, todayTime)
  46. mainStr := payGoodsTip
  47. if payGoodsTipType == "1" {
  48. mainStr = payGoodsSecondTip
  49. }
  50. for k, v := range nativeString {
  51. sql1 := `select title,num,sku_info from community_team_order_info
  52. where oid=?
  53. `
  54. queryNativeString, _ := db.QueryNativeString(svc.MasterDb(c), sql1, v["oid"])
  55. str := ""
  56. for _, v1 := range queryNativeString {
  57. tmp := make([]map[string]interface{}, 0)
  58. json.Unmarshal([]byte(v["sku_info"]), &tmp)
  59. skuStr := ""
  60. for _, v2 := range tmp {
  61. skuStr += utils.AnyToString(v2["value"])
  62. }
  63. str += " " + v1["title"] + skuStr + v1["num"] + " 份"
  64. }
  65. if payGoodsTipType == "1" {
  66. list = append(list, mainStr+str)
  67. }
  68. if payGoodsTipType != "1" && k == 0 {
  69. list = append(list, mainStr)
  70. }
  71. svc.MasterDb(c).Where("oid=? ", v["oid"]).Cols("is_notice").Update(&model.CommunityTeamOrder{IsNotice: 1})
  72. }
  73. }
  74. res := map[string]interface{}{
  75. "list": list,
  76. }
  77. e.OutSuc(c, res, nil)
  78. return
  79. }