From 80e39e3a40283521fc732c930aa51d9bece7c146 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期三, 03 六月 2020 15:15:49 +0800 Subject: [PATCH] 云发单 后台管理 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCloudControllerV2.java | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 43 insertions(+), 9 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCloudControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCloudControllerV2.java index e0f36ed..429ddf1 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCloudControllerV2.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserCloudControllerV2.java @@ -34,6 +34,7 @@ import com.yeshi.fanli.entity.bus.user.cloud.UserCloudOrder; import com.yeshi.fanli.entity.dynamic.GoodsEvaluate; import com.yeshi.fanli.entity.goods.CommonGoods; +import com.yeshi.fanli.entity.system.ConfigKeyEnum; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.exception.taobao.TaoKeApiException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; @@ -41,6 +42,7 @@ import com.yeshi.fanli.exception.user.cloud.UserCloudGoodsException; import com.yeshi.fanli.exception.user.cloud.UserCloudGroupException; import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService; import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; import com.yeshi.fanli.service.inter.user.UserInfoService; @@ -55,6 +57,7 @@ import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.aitaoker.AitaokerApiUtil; import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; +import com.yeshi.fanli.util.suning.SuningUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import com.yeshi.fanli.vo.goods.GoodsDetailVO; import com.yeshi.fanli.vo.user.cloud.UserCloudInfoVO; @@ -93,7 +96,8 @@ @Resource private GoodsEvaluateService goodsEvaluateService; - + @Resource + private ConfigService configService; /** * 鏌ヨ寮�閫氳褰� @@ -575,7 +579,7 @@ * @param out */ @RequestMapping(value = "accordGoods") - public void accordGoods(String callback, AcceptData acceptData, Long uid, Long goodsId, Integer goodsType, + public void accordGoods(String callback, AcceptData acceptData, Long uid, String goodsId, Integer goodsType, PrintWriter out) { if (uid == null) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); @@ -589,11 +593,17 @@ try { boolean state = false; - UserCloudGoods cloudGoods = userCloudGoodsService.getByUidAndGoods(uid, goodsId, goodsType); + String queryGoodsId = goodsId; + if (goodsType == Constant.SOURCE_TYPE_SUNING) { // 鑻忓畞 + String[] ids = SuningUtil.getGoodsIdDetail(goodsId); + queryGoodsId = ids[1]; + } + + UserCloudGoods cloudGoods = userCloudGoodsService.getByUidAndGoods(uid, Long.parseLong(queryGoodsId), goodsType); if (cloudGoods != null) { // 鍙栨秷鍔犲叆閫夊搧搴� userCloudGoodsService.deleteByPrimaryKeyAndUid(cloudGoods.getId(), uid); } else { // 鍔犲叆閫夊搧搴� - Set<Long> set = new HashSet<Long>(); + Set<String> set = new HashSet<String>(); set.add(goodsId); userCloudGoodsService.addGoods(uid, set, goodsType); state = true; @@ -742,7 +752,14 @@ userCloudService.sendByDynamic(uid, id); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("涓�閿彂鍗曟垚鍔�")); } catch (UserCloudException e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(),e.getMsg())); + if (e.getCode() > 1000) { + JSONObject data = new JSONObject(); + data.put("msg", e.getMsg()); + data.put("link", configService.get(ConfigKeyEnum.robotCloudLink.getKey())); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(1000, data)); + } else { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(),e.getMsg())); + } } } @@ -757,22 +774,39 @@ * @param out */ @RequestMapping(value = "sendGoods") - public void sendGoods(String callback, AcceptData acceptData, Long uid, Long goodsId, Integer goodsType, PrintWriter out) { + public void sendGoods(String callback, AcceptData acceptData, Long uid, String goodsId, Integer goodsType, PrintWriter out) { if (uid == null || goodsId == null || goodsType == null) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍙傛暟涓嶈兘涓虹┖")); return; } try { - GoodsEvaluate evaluate = goodsEvaluateService.queryExistSingle(goodsId +"", goodsType); + GoodsEvaluate evaluate = goodsEvaluateService.queryExistSingle(goodsId, goodsType); if (evaluate != null) { userCloudService.sendByDynamic(uid, evaluate.getId()); } else { - userCloudService.sendCustomGoods(uid, goodsId, goodsType); + + Long gid = null; + Long sellerId = null; + if (goodsType == Constant.SOURCE_TYPE_SUNING) { // 鑻忓畞 + String[] ids = SuningUtil.getGoodsIdDetail(goodsId); + gid = Long.parseLong(ids[1]); + sellerId = Long.parseLong(ids[0]); + } else { + gid = Long.parseLong(goodsId); + } + + userCloudService.sendCustomGoods(uid, gid, goodsType, sellerId); } JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("涓�閿彂鍗曟垚鍔�")); } catch (UserCloudException e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(),e.getMsg())); + if (e.getCode() > 1000 && e.getCode() < 1100) { + JSONObject data = new JSONObject(); + data.put("link", configService.get(ConfigKeyEnum.robotCloudLink.getKey())); + JsonUtil.printMode(out, callback, JsonUtil.loadTrue(e.getCode(), data, e.getMsg()).toString()); + } else { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(),e.getMsg())); + } } } } -- Gitblit v1.8.0