From 88b54772dbcf5ecab1e2316e4e4626ac901b8908 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期二, 22 一月 2019 15:58:24 +0800 Subject: [PATCH] 邀请码添加返回状态 --- fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java | 97 ++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 80 insertions(+), 17 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java index 18fc9c4..29b75e3 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java @@ -9,12 +9,10 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.yeshi.utils.BigDecimalUtil; import org.yeshi.utils.HttpUtil; import org.yeshi.utils.JsonUtil; import org.yeshi.utils.taobao.TbImgUtil; @@ -26,7 +24,9 @@ import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.taobao.TaoBaoLink; import com.yeshi.fanli.exception.ShareGoodsException; +import com.yeshi.fanli.exception.share.UserShareGoodsRecordException; import com.yeshi.fanli.service.inter.config.ConfigService; +import com.yeshi.fanli.service.inter.goods.CommonGoodsService; import com.yeshi.fanli.service.inter.goods.ShareGoodsService; import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; import com.yeshi.fanli.service.inter.monitor.MonitorService; @@ -37,6 +37,9 @@ import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.factory.MonitorFactory; import com.yeshi.fanli.util.taobao.TaoBaoUtil; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; @Controller(value = "ShareController1") @RequestMapping("api/v1/share") @@ -53,12 +56,15 @@ @Resource private MonitorService monitorService; - + @Resource private UserShareGoodsRecordService userShareGoodsRecordService; - + @Resource private UserShareGoodsGroupService userShareGoodsGroupService; + + @Resource + private CommonGoodsService commonGoodsService; // 鑾峰彇鍟嗗搧鍒嗕韩閾炬帴 @RequestMapping(value = "getGoodsShareUrl") @@ -93,7 +99,7 @@ TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId); JSONObject data = new JSONObject(); - String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(), + String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(), Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY), auctionId + ""); @@ -121,11 +127,13 @@ String text = configService.get("goods_share_text_coupon"); shareText = text.replace("[鏍囬]", taoBaoLink.getGoods().getTitle()) .replace("[鍦ㄥ敭浠穄", "楼" + taoBaoLink.getGoods().getZkPrice()) + .replace("[浼樻儬鍒搁噾棰漖", + "楼" + BigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString()) .replace("[鍒稿悗浠穄", "楼" + TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods())); } shareText = shareText.replace("[浠锋牸绫诲瀷]", shopType); data.put("shareText", shareText); - String descText = shareText.replace(taoBaoLink.getGoods().getTitle() + "\r\n", ""); + String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim(); if (descText.startsWith("\\r\\n")) descText = descText.substring(0); data.put("descText", descText); @@ -138,7 +146,7 @@ data.put("notifyDesc", configService.get("goods_share_notify")); // 娣诲姞鍒嗕韩璁板綍 - BigDecimal rate =hongBaoManageService.getFanLiRate(); + BigDecimal rate = hongBaoManageService.getShareRate(); UserShareGoodsHistory history = new UserShareGoodsHistory(); history.setTkCode(taoBaoLink.getTaoToken()); history.setLink(taoBaoLink.getClickUrl()); @@ -155,6 +163,8 @@ history.setPictures(JsonUtil.getGson().toJson(imgList)); history.setUser(new UserInfo(uid)); history.setPostPicture(taoBaoLink.getGoods().getPictUrl()); + + data.put("shareMoney", "楼" + history.getHongbao().toString()); out.print(JsonUtil.loadTrueResult(data)); @@ -176,11 +186,13 @@ } } - + /** * 鍒嗕韩璁板綍缁熻鍒楄〃 + * * @param acceptData - * @param page 鍒濆1 + * @param page + * 鍒濆1 * @param uid * @param source * @param out @@ -195,7 +207,7 @@ if (uid == null) { out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); } - + if ("all".equals(source)) { source = null;// 鏌ヨ鍏ㄩ儴 } @@ -207,7 +219,7 @@ List<UserShareGoodsRecord> list = new ArrayList<UserShareGoodsRecord>(); long count = userShareGoodsRecordService.countQueryByUid(uid, source); - + if (count > 0) { list = userShareGoodsRecordService.getMyShareGoodsRecords((page - 1) * pageSize, pageSize, uid, source); } @@ -222,9 +234,9 @@ } } - /** * 鑾峰彇鍒嗕韩鍟嗗搧 + * * @param acceptData * @param recordId * @param out @@ -237,16 +249,17 @@ } try { - JSONObject data = userShareGoodsGroupService.getGoodsGroup(recordId); + JSONObject data = userShareGoodsRecordService.getGoodsGroup(recordId); out.print(JsonUtil.loadTrueResult(data)); } catch (Exception e) { out.print(JsonUtil.loadFalseResult("鍔犺浇澶辫触")); e.printStackTrace(); } } - + /** * 鑾峰彇鍒嗕韩鍟嗗搧鍗曚釜缁熻淇℃伅 + * * @param acceptData * @param groupId * @param out @@ -266,7 +279,7 @@ userShareGoodsGroup.setUpdateTime(null); userShareGoodsGroup.setRecordId(null); } - + JSONObject data = new JSONObject(); data.put("goodsData", userShareGoodsGroup); out.print(JsonUtil.loadTrueResult(data)); @@ -275,6 +288,56 @@ e.printStackTrace(); } } - + + /** + * 鍟嗗搧璇︽儏鍒嗕韩 + * + * @param acceptData + * @param uid + * 鐢ㄦ埛id + * @param auctionId + * 鍟嗗搧id + * @param type + * 鍥剧墖鍒嗕韩绫诲瀷 鍗曞浘single 澶氬浘many + * @param out + */ + @RequestMapping(value = "sharedetail", method = RequestMethod.POST) + public void shareDetail(AcceptData acceptData, Long uid, Long auctionId, String type, PrintWriter out) { + try { + userShareGoodsRecordService.saveDetail(uid, auctionId, type); + out.print(JsonUtil.loadTrueResult("鍒嗕韩鎴愬姛")); + } catch (UserShareGoodsRecordException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + e.printStackTrace(); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("鍔犺浇澶辫触")); + e.printStackTrace(); + } + } + + /** + * 鏇存柊鍒嗕韩璁板綍 + * + * @param acceptData + * @param shareId + * @param out + */ + @RequestMapping(value = "updaterecord", method = RequestMethod.POST) + public void updateRecord(AcceptData acceptData, Long shareId, PrintWriter out) { + if (shareId == null) { + out.print(JsonUtil.loadFalseResult("鍙傛暟涓嶆纭�")); + } + + try { + userShareGoodsRecordService.updateShareRecord(shareId); + out.print(JsonUtil.loadTrueResult("")); + } catch (UserShareGoodsRecordException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + e.printStackTrace(); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("鍔犺浇澶辫触")); + e.printStackTrace(); + } + } } -- Gitblit v1.8.0