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

hdl_store.go 17 KiB

2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
2 months ago
1 month ago
2 months ago
2 months ago
1 month ago
2 months ago
2 weeks ago
2 months ago
2 weeks ago
2 months ago
2 weeks ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 weeks ago
2 months ago
2 weeks ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. package hdl
  2. import (
  3. "applet/app/db"
  4. "applet/app/db/model"
  5. "applet/app/e"
  6. "applet/app/md"
  7. storeSvc "applet/app/store/svc"
  8. "applet/app/svc"
  9. "applet/app/utils"
  10. "encoding/json"
  11. "fmt"
  12. "github.com/gin-gonic/gin"
  13. "github.com/tidwall/gjson"
  14. "time"
  15. )
  16. // UserStoreList 门店列表
  17. // @Summary 门店-列表
  18. // @Tags 门店
  19. // @Description 门店-列表
  20. // @Accept json
  21. // @Produce json
  22. // @Param req body md.Store true "请求参数"
  23. // @Success 200 {string} ""
  24. // @Failure 400 {object} md.Response "具体错误"
  25. // @Router /api/v1/communityTeam/ownStore/store/list [POST]
  26. func UserStoreList(c *gin.Context) {
  27. var arg md.Store
  28. if err := c.ShouldBindJSON(&arg); err != nil {
  29. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  30. return
  31. }
  32. user := svc.GetUser(c)
  33. list, count := db.GetUserList(svc.MasterDb(c), arg, user.Info.Uid)
  34. data := make([]map[string]interface{}, 0)
  35. if list != nil {
  36. currentMonth := utils.GetTimeRange("current_month")
  37. for _, v := range *list {
  38. store := v.CommunityTeamStore
  39. tmp := map[string]interface{}{
  40. "uid": utils.IntToStr(v.User.Uid),
  41. "create_at": store.CreateAt.Format("2006-01-02 15:04:05"),
  42. "name": "",
  43. "address": "",
  44. "logo": "",
  45. "order_count": "0",
  46. "order_amount": "0",
  47. "agent_commission": "0",
  48. "platform_commission": "0",
  49. "base_commission": "0",
  50. "work_state": "",
  51. }
  52. count1, _ := svc.MasterDb(c).Where("store_uid=? and parent_uid=?", v.User.Uid, user.Info.Uid).In("state", []string{"1", "2"}).Count(&model.CommunityTeamOrder{})
  53. sum, _ := svc.MasterDb(c).Where("store_uid=? and parent_uid=? and create_at>=?", v.User.Uid, user.Info.Uid, time.Unix(currentMonth["start"], 0).Format("2006-01-02 15:04:05")).In("state", []string{"1", "2"}).Sum(&model.CommunityTeamOrder{}, "amount")
  54. tmp["order_count"] = utils.Int64ToStr(count1)
  55. tmp["order_amount"] = svc.GetCommissionPrec(c, utils.Float64ToStr(sum), "2", "")
  56. tmp["name"] = store.Name
  57. tmp["address"] = store.Address
  58. tmp["logo"] = store.Logo
  59. tmp["work_state"] = "营业中"
  60. if store.WorkState == 1 {
  61. tmp["work_state"] = "休息中"
  62. }
  63. tmp["agent_commission"] = store.AgentCommission
  64. data = append(data, tmp)
  65. }
  66. }
  67. res := map[string]interface{}{
  68. "total": count,
  69. "list": data,
  70. }
  71. e.OutSuc(c, res, nil)
  72. }
  73. // UserStoreSave 门店编辑
  74. // @Summary 门店-门店编辑
  75. // @Tags 门店
  76. // @Description 门店-门店编辑
  77. // @Accept json
  78. // @Produce json
  79. // @Param req body md.StoreSave true "请求参数"
  80. // @Success 200 {string} ""
  81. // @Failure 400 {object} md.Response "具体错误"
  82. // @Router /api/v1/communityTeam/ownStore/store/save [POST]
  83. func UserStoreSave(c *gin.Context) {
  84. var arg md.StoreSave
  85. if err := c.ShouldBindJSON(&arg); err != nil {
  86. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  87. return
  88. }
  89. store := db.GetUserStore(svc.MasterDb(c), utils.StrToInt(arg.Uid))
  90. if store == nil {
  91. e.OutErr(c, 400, e.NewErr(400, "门店不存在"))
  92. return
  93. }
  94. store.AgentCommission = arg.AgentCommission
  95. svc.MasterDb(c).Where("id=?", store.Id).Cols("agent_commission").Update(store)
  96. e.OutSuc(c, "success", nil)
  97. return
  98. }
  99. // UserStoreOrder 门店订单-订单管理共用一个
  100. // @Summary 门店-门店订单
  101. // @Tags 门店
  102. // @Description 门店-门店订单
  103. // @Accept json
  104. // @Produce json
  105. // @Param req body md.StoreOrder true "请求参数"
  106. // @Success 200 {string} ""
  107. // @Failure 400 {object} md.Response "具体错误"
  108. // @Router /api/v1/communityTeam/ownStore/store/order [POST]
  109. func UserStoreOrder(c *gin.Context) {
  110. var arg md.StoreOrder
  111. if err := c.ShouldBindJSON(&arg); err != nil {
  112. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  113. return
  114. }
  115. user := svc.GetUser(c)
  116. arg.StoreUid = utils.IntToStr(user.Info.Uid)
  117. data, total, _ := db.GetStoreOrderList(svc.MasterDb(c), arg, 0)
  118. list := make([]map[string]string, 0)
  119. if data != nil {
  120. stateList := []string{"待付款", "已支付", "已提货", "已取消"}
  121. for _, v := range *data {
  122. tmp := map[string]string{
  123. "oid": utils.Int64ToStr(v.Oid),
  124. "uid": utils.IntToStr(v.Uid),
  125. "phone": "",
  126. "nickname": "",
  127. "store_name": "",
  128. "state_str": stateList[v.State],
  129. "amount": v.Amount,
  130. "agent_commission": v.AgentCommission,
  131. "platform_commission": v.PlatformCommission,
  132. "commission": v.Commission,
  133. "table_num": v.TableNum,
  134. "state": utils.IntToStr(v.State),
  135. "create_at": v.CreateAt.Format("2006-01-02 15:04:05"),
  136. "confirm_at": utils.Int64ToStr(v.Oid),
  137. }
  138. if v.ConfirmAt.IsZero() == false {
  139. tmp["confirm_at"] = v.ConfirmAt.Format("2006-01-02 15:04:05")
  140. }
  141. user1, _ := db.UserFindByID(svc.MasterDb(c), v.Uid)
  142. if user1 != nil {
  143. tmp["phone"] = user1.Phone
  144. tmp["nickname"] = user1.Nickname
  145. }
  146. store := db.GetUserStore(svc.MasterDb(c), v.StoreUid)
  147. if store != nil {
  148. tmp["store_name"] = store.Name
  149. }
  150. list = append(list, tmp)
  151. }
  152. }
  153. res := map[string]interface{}{
  154. "total": total,
  155. "state": []map[string]string{
  156. {"name": "待付款", "value": "0"},
  157. {"name": "已支付", "value": "1"},
  158. {"name": "已提货", "value": "2"},
  159. {"name": "已取消", "value": "3"},
  160. },
  161. "list": list,
  162. }
  163. e.OutSuc(c, res, nil)
  164. }
  165. func UserStoreOrderPay(c *gin.Context) {
  166. var arg map[string]string
  167. if err := c.ShouldBindJSON(&arg); err != nil {
  168. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  169. return
  170. }
  171. user := svc.GetUser(c)
  172. str := "ctpo.store_uid=" + utils.IntToStr(user.Info.Uid) + " and ctpo.state=1"
  173. if arg["uid"] != "" {
  174. str += " and ctpo.uid=" + arg["uid"]
  175. }
  176. if arg["phone"] != "" {
  177. str += " and u.phone like '%" + arg["phone"] + "%'"
  178. }
  179. if arg["oid"] != "" {
  180. str += " and ctpo.oid like '%" + arg["oid"] + "%'"
  181. }
  182. if arg["start_time"] != "" {
  183. str += " and ctpo.pay_at>='" + arg["start_time"] + "'"
  184. }
  185. if arg["end_time"] != "" {
  186. str += " and ctpo.pay_at<='" + arg["end_time"] + "'"
  187. }
  188. sql := `select ctpo.pay_at,ctpo.oid,u.phone,ctpo.uid,ctpo.amount,ctpo.agent_commission,ctpo.platform_commission from community_team_pay_order ctpo
  189. LEFT JOIN user u on u.uid=ctpo.uid
  190. where %s order by ctpo.pay_at desc %s`
  191. size := utils.StrToInt(arg["size"])
  192. start := (utils.StrToInt(arg["p"]) - 1) * size
  193. sql = fmt.Sprintf(sql, str, "limit "+utils.IntToStr(start)+","+utils.IntToStr(size))
  194. nativeString, _ := db.QueryNativeString(svc.MasterDb(c), sql)
  195. list := make([]map[string]string, 0)
  196. for _, v := range nativeString {
  197. tmp := map[string]string{
  198. "time": v["pay_at"],
  199. "amount": v["amount"],
  200. "phone": v["phone"],
  201. "uid": v["uid"],
  202. "agent_commission": v["agent_commission"],
  203. "platform_commission": v["platform_commission"],
  204. "oid": v["oid"],
  205. }
  206. list = append(list, tmp)
  207. }
  208. sql1 := `select COUNT(*) as count from community_team_pay_order ctpo
  209. LEFT JOIN user u on u.uid=ctpo.uid
  210. where %s `
  211. sql = fmt.Sprintf(sql, str)
  212. nativeString1, _ := db.QueryNativeString(svc.MasterDb(c), sql1)
  213. total := 0
  214. for _, v := range nativeString1 {
  215. total = utils.StrToInt(v["count"])
  216. }
  217. res := map[string]interface{}{
  218. "total": total,
  219. "list": list,
  220. }
  221. e.OutSuc(c, res, nil)
  222. return
  223. }
  224. // UserStoreOrderDetail 门店订单详情-订单管理共用一个
  225. // @Summary 门店-门店订单详情
  226. // @Tags 门店
  227. // @Description 门店-门店订单详情
  228. // @Accept json
  229. // @Produce json
  230. // @Param req body md.StoreOrderDetail true "请求参数"
  231. // @Success 200 {string} ""
  232. // @Failure 400 {object} md.Response "具体错误"
  233. // @Router /api/v1/communityTeam/ownStore/store/order/detail [POST]
  234. func UserStoreOrderDetail(c *gin.Context) {
  235. var arg md.StoreOrderDetail
  236. if err := c.ShouldBindJSON(&arg); err != nil {
  237. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  238. return
  239. }
  240. order := db.GetOrderByOid(svc.MasterDb(c), arg.Oid)
  241. if order == nil {
  242. e.OutErr(c, 400, e.NewErr(400, "订单不存在"))
  243. return
  244. }
  245. stateList := []string{"待付款", "已支付", "已提货", "已取消"}
  246. payMethodStr := []string{"", "余额支付", "支付宝支付", "微信支付"}
  247. orderInfoMap := make([]map[string]string, 0)
  248. res := map[string]interface{}{
  249. "oid": utils.Int64ToStr(order.Oid),
  250. "uid": utils.IntToStr(order.Uid),
  251. "phone": order.Phone,
  252. "nickname": "",
  253. "store_name": "",
  254. "memo": order.Memo,
  255. "coupon": order.Coupon,
  256. "code": order.Code,
  257. "amount": order.Amount,
  258. "all_amount": utils.Float64ToStr(utils.StrToFloat64(order.Amount) + utils.StrToFloat64(order.Coupon)),
  259. "pay_method_str": payMethodStr[order.PayMethod],
  260. "state_str": stateList[order.State],
  261. "state": utils.IntToStr(order.State),
  262. "create_at": order.CreateAt.Format("2006-01-02 15:04:05"),
  263. "confirm_at": "",
  264. "pay_at": "",
  265. "order_info": orderInfoMap,
  266. }
  267. if order.ConfirmAt.IsZero() == false {
  268. res["confirm_at"] = order.ConfirmAt.Format("2006-01-02 15:04:05")
  269. } else {
  270. res["confirm_at"] = order.Timer
  271. if order.IsNow == 1 {
  272. res["confirm_at"] = "立即提货"
  273. }
  274. }
  275. if order.PayAt.IsZero() == false {
  276. res["pay_at"] = order.PayAt.Format("2006-01-02 15:04:05")
  277. }
  278. user, _ := db.UserFindByID(svc.MasterDb(c), order.Uid)
  279. if user != nil {
  280. res["nickname"] = user.Nickname
  281. if order.Phone == "" {
  282. res["phone"] = user.Phone
  283. }
  284. }
  285. store := db.GetUserStore(svc.MasterDb(c), order.StoreUid)
  286. if store != nil {
  287. res["store_name"] = store.Name
  288. }
  289. orderInfo := db.GetOrderInfoAllEg(svc.MasterDb(c), arg.Oid)
  290. if orderInfo != nil {
  291. scheme, host := svc.ImageBucket(c)
  292. for _, v := range *orderInfo {
  293. skuData := make([]md.Sku, 0)
  294. json.Unmarshal([]byte(v.SkuInfo), &skuData)
  295. skuStr := ""
  296. for _, v1 := range skuData {
  297. if skuStr != "" {
  298. skuStr += ";"
  299. }
  300. skuStr += v1.Value
  301. }
  302. tmp := map[string]string{
  303. "sku_str": skuStr,
  304. "goods_title": v.Title,
  305. "goods_img": svc.ImageFormatWithBucket(scheme, host, v.Img),
  306. "num": utils.IntToStr(v.Num),
  307. "amount": utils.Float64ToStr(float64(v.Num) * utils.StrToFloat64(v.Price)),
  308. }
  309. orderInfoMap = append(orderInfoMap, tmp)
  310. }
  311. res["order_info"] = orderInfoMap
  312. }
  313. e.OutSuc(c, res, nil)
  314. return
  315. }
  316. func StoreOrderConfirm(c *gin.Context) {
  317. storeSvc.StoreOrderConfirm(c)
  318. }
  319. func UserStoreInfo(c *gin.Context) {
  320. user := svc.GetUser(c)
  321. data, _ := db.SysModFindBySkipIdentifierWithUid(c, svc.MasterDb(c), "pub.flutter.user_store", user.Info.Uid)
  322. if data == nil {
  323. data = &model.SysModule{
  324. ModName: "user_store",
  325. Position: "user_store",
  326. SkipIdentifier: "pub.flutter.user_store",
  327. Title: "店铺模板",
  328. Uid: user.Info.Uid,
  329. State: 1,
  330. Data: "{\"icon\":\"\",\"icon_url\":\"\",\"name\":\"\",\"store_detail_url\":\"\",\"address\":\"\",\"phone\":\"\",\"time_str\":\"\",\"notice_str\":\"\",\"banner_title\":\"\",\"activity_title\":\"\"}",
  331. Platform: 1,
  332. CreateAt: time.Now(),
  333. UpdateAt: time.Now(),
  334. }
  335. svc.MasterDb(c).Insert(data)
  336. }
  337. var tmp = make(map[string]interface{})
  338. json.Unmarshal([]byte(data.Data), &tmp)
  339. h5Domain := svc.GetWebSiteDomainInfo(c, "wap")
  340. store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  341. if store != nil {
  342. tmp["icon"] = store.Logo
  343. tmp["icon_url"] = store.Logo
  344. tmp["name"] = store.Name
  345. tmp["address"] = store.Address
  346. tmp["phone"] = store.Phone
  347. tmp["lat"] = store.Lat
  348. tmp["lng"] = store.Lng
  349. tmp["province"] = store.Province
  350. tmp["city"] = store.City
  351. tmp["district"] = store.District
  352. tmp["province_id"] = store.ProvinceId
  353. tmp["city_id"] = store.CityId
  354. tmp["district_id"] = store.DistrictId
  355. tmp["work_state"] = utils.IntToStr(store.WorkState)
  356. }
  357. tmp["share_url"] = h5Domain + "/#/zy-user-store/pages/store-page/index?uid=" + utils.IntToStr(user.Info.Uid)
  358. e.OutSuc(c, tmp, nil)
  359. return
  360. }
  361. func UserStoreInfoSet(c *gin.Context) {
  362. var arg map[string]interface{}
  363. if err := c.ShouldBindJSON(&arg); err != nil {
  364. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  365. return
  366. }
  367. user := svc.GetUser(c)
  368. data, _ := db.SysModFindBySkipIdentifierWithUid(c, svc.MasterDb(c), "pub.flutter.user_store", user.Info.Uid)
  369. data.Data = utils.SerializeStr(arg)
  370. svc.MasterDb(c).Where("mod_id=?", data.ModId).Cols("data").Update(data)
  371. store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  372. if store == nil {
  373. store = &model.CommunityTeamStore{
  374. Uid: user.Info.Uid,
  375. CreateAt: time.Now(),
  376. UpdateAt: time.Now(),
  377. State: 1,
  378. }
  379. svc.MasterDb(c).Insert(store)
  380. }
  381. if gjson.Get(data.Data, "address").String() != "" {
  382. store.Address = gjson.Get(data.Data, "address").String()
  383. }
  384. if gjson.Get(data.Data, "lat").String() != "" {
  385. store.Lat = gjson.Get(data.Data, "lat").String()
  386. }
  387. if gjson.Get(data.Data, "lng").String() != "" {
  388. store.Lng = gjson.Get(data.Data, "lng").String()
  389. }
  390. if gjson.Get(data.Data, "province").String() != "" {
  391. store.Province = gjson.Get(data.Data, "province").String()
  392. }
  393. if gjson.Get(data.Data, "city").String() != "" {
  394. store.City = gjson.Get(data.Data, "city").String()
  395. }
  396. if gjson.Get(data.Data, "district").String() != "" {
  397. store.District = gjson.Get(data.Data, "district").String()
  398. }
  399. if gjson.Get(data.Data, "province_id").String() != "" {
  400. store.ProvinceId = utils.StrToInt(gjson.Get(data.Data, "province_id").String())
  401. }
  402. if gjson.Get(data.Data, "city_id").String() != "" {
  403. store.CityId = utils.StrToInt(gjson.Get(data.Data, "city_id").String())
  404. }
  405. if gjson.Get(data.Data, "district_id").String() != "" {
  406. store.DistrictId = utils.StrToInt(gjson.Get(data.Data, "district_id").String())
  407. }
  408. if gjson.Get(data.Data, "name").String() != "" {
  409. store.Name = gjson.Get(data.Data, "name").String()
  410. }
  411. if gjson.Get(data.Data, "work_state").String() != "" {
  412. store.WorkState = utils.StrToInt(gjson.Get(data.Data, "work_state").String())
  413. }
  414. if gjson.Get(data.Data, "time_str").String() != "" {
  415. store.Timer = gjson.Get(data.Data, "time_str").String()
  416. }
  417. if gjson.Get(data.Data, "phone").String() != "" {
  418. store.Phone = gjson.Get(data.Data, "phone").String()
  419. }
  420. if gjson.Get(data.Data, "icon_url").String() != "" {
  421. store.Logo = gjson.Get(data.Data, "icon_url").String()
  422. }
  423. svc.MasterDb(c).Where("id=?", store.Id).Cols("province_id,city_id,district_id,timer,phone,logo,work_state,name,province,city,district,address,lat,lng").Update(store)
  424. e.OutSuc(c, "success", nil)
  425. return
  426. }
  427. func UserStoreBanner(c *gin.Context) {
  428. var arg map[string]string
  429. if err := c.ShouldBindJSON(&arg); err != nil {
  430. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  431. return
  432. }
  433. user := svc.GetUser(c)
  434. uid := user.Info.Uid
  435. activity := db.GetUserStoreActivity(svc.MasterDb(c), arg["type"], uid)
  436. data := make([]map[string]string, 0)
  437. if activity != nil {
  438. scheme := svc.SysCfgGet(c, "file_bucket_scheme")
  439. domain := svc.SysCfgGet(c, "file_bucket_host")
  440. linkTypeStr := []string{"内链分享", "外链分享"}
  441. scheme, host := svc.ImageBucket(c)
  442. for _, v := range *activity {
  443. tmp := map[string]string{
  444. "id": utils.IntToStr(v.Id),
  445. "title": v.Title,
  446. "link_type_str": linkTypeStr[v.LinkType],
  447. "img": svc.ImageFormatWithBucket(scheme, host, v.Img),
  448. "img_url": svc.ImageFormatWithBucket(scheme, domain, v.Img),
  449. "label": v.Label,
  450. "uid": utils.IntToStr(v.Uid),
  451. }
  452. data = append(data, tmp)
  453. }
  454. }
  455. e.OutSuc(c, data, nil)
  456. return
  457. }
  458. func UserStoreBannerDetail(c *gin.Context) {
  459. var arg map[string]string
  460. if err := c.ShouldBindJSON(&arg); err != nil {
  461. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  462. return
  463. }
  464. data := db.GetUserStoreActivityById(svc.MasterDb(c), arg["id"])
  465. if data == nil {
  466. e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
  467. return
  468. }
  469. scheme := svc.SysCfgGet(c, "file_bucket_scheme")
  470. domain := svc.SysCfgGet(c, "file_bucket_host")
  471. res := map[string]string{
  472. "id": utils.IntToStr(data.Id),
  473. "uid": utils.IntToStr(data.Uid),
  474. "title": data.Title,
  475. "img": data.Img,
  476. "img_url": svc.ImageFormatWithBucket(scheme, domain, data.Img),
  477. "label": data.Label,
  478. "content": data.Content,
  479. "type": data.Type,
  480. "url": data.Url,
  481. "link_type": utils.IntToStr(data.LinkType),
  482. "sort": utils.IntToStr(data.Sort),
  483. }
  484. e.OutSuc(c, res, nil)
  485. return
  486. }
  487. func UserStoreBannerSave(c *gin.Context) {
  488. var arg map[string]string
  489. if err := c.ShouldBindJSON(&arg); err != nil {
  490. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  491. return
  492. }
  493. user := svc.GetUser(c)
  494. data := model.UserStoreActivity{}
  495. if arg["id"] == "" {
  496. data = model.UserStoreActivity{
  497. Uid: user.Info.Uid,
  498. Type: arg["type"],
  499. Time: time.Now(),
  500. }
  501. svc.MasterDb(c).Insert(&data)
  502. } else {
  503. svc.MasterDb(c).Where("id=?", arg["id"]).Get(&data)
  504. }
  505. data.Label = arg["label"]
  506. data.Img = arg["img"]
  507. data.Title = arg["title"]
  508. data.Content = arg["content"]
  509. data.LinkType = utils.StrToInt(arg["link_type"])
  510. data.Url = arg["url"]
  511. data.Sort = utils.StrToInt(arg["sort"])
  512. svc.MasterDb(c).Where("id=?", data.Id).Update(&data)
  513. e.OutSuc(c, "success", nil)
  514. return
  515. }
  516. func UserStoreBannerDel(c *gin.Context) {
  517. var arg map[string]string
  518. if err := c.ShouldBindJSON(&arg); err != nil {
  519. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  520. return
  521. }
  522. svc.MasterDb(c).Where("id=?", arg["id"]).Delete(&model.UserStoreActivity{})
  523. e.OutSuc(c, "success", nil)
  524. return
  525. }