From bd82387a76962a1e785197667e63ec77c6a9b73b Mon Sep 17 00:00:00 2001 From: lifenlong Date: Thu, 24 Jun 2021 15:29:23 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=99=9A=E6=8B=9F=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E4=BF=AE=E6=94=B9=E6=94=B6=E4=BB=B6=E4=BA=BA?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lili/modules/order/order/entity/vo/AllowOperation.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AllowOperation.java b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AllowOperation.java index dd8a1e9a..29a956e5 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AllowOperation.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AllowOperation.java @@ -69,8 +69,9 @@ public class AllowOperation implements Serializable { //新订单,允许支付 this.pay = status.equals(OrderStatusEnum.UNPAID.name()) && payStatus.equals(PayStatusEnum.UNPAID.name()); - //订单未发货,就可以编辑收货人信息 - this.editConsignee = order.getDeliverStatus().equals(DeliverStatusEnum.UNDELIVERED.name()) && !status.equals(OrderStatusEnum.CANCELLED.name()); + //订单未发货,就可以编辑收货人信息(实物订单) + this.editConsignee = order.getOrderType().equals(OrderTypeEnum.VIRTUAL.name()) && + order.getDeliverStatus().equals(DeliverStatusEnum.UNDELIVERED.name()) && !status.equals(OrderStatusEnum.CANCELLED.name()); //是否允许被发货 this.ship = editConsignee && status.equals(OrderStatusEnum.UNDELIVERED.name()); From e6ad65d8c0fa90e76a737388ce28b241d06d23b8 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Thu, 24 Jun 2021 15:51:14 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=8F=91=E8=A1=8C?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E6=98=AF0,=E5=88=99=E4=B8=8D=E9=99=90?= =?UTF-8?q?=E5=88=B6=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/promotion/entity/dos/Coupon.java | 2 +- .../modules/promotion/serviceimpl/CouponServiceImpl.java | 6 +++--- .../promotion/serviceimpl/MemberCouponServiceImpl.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Coupon.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Coupon.java index 9c9739e0..1188a79a 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Coupon.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Coupon.java @@ -66,7 +66,7 @@ public class Coupon extends BasePromotion { @ApiModelProperty(value = "活动描述") private String description; - @ApiModelProperty(value = "发行数量") + @ApiModelProperty(value = "发行数量,如果是0则是不限制") private Integer publishNum; @ApiModelProperty(value = "领取限制") diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java index 16111412..de3683db 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/CouponServiceImpl.java @@ -271,8 +271,8 @@ public class CouponServiceImpl extends ServiceImpl impleme if (coupon.getCouponLimitNum() < 0) { throw new ServiceException("领取限制数量不能为负数"); } - - if (coupon.getCouponLimitNum() > coupon.getPublishNum()) { + //如果发行数量是0则判断领取限制数量 + if (coupon.getPublishNum() != 0 && coupon.getCouponLimitNum() > coupon.getPublishNum()) { throw new ServiceException("领取限制数量超出发行数量"); } @@ -282,7 +282,7 @@ public class CouponServiceImpl extends ServiceImpl impleme throw new ServiceException("优惠券折扣必须小于10且大于0"); } - if (coupon.getRangeDayType().equals(CouponRangeDayEnum.FIXEDTIME.name())) { + if (coupon.getRangeDayType() != null && coupon.getRangeDayType().equals(CouponRangeDayEnum.FIXEDTIME.name())) { long nowTime = DateUtil.getDateline() * 1000; if (coupon.getStartTime().getTime() < nowTime && coupon.getEndTime().getTime() > nowTime) { throw new ServiceException("活动时间小于当前时间,不能进行编辑删除操作"); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java index 7ac348ca..b5177a18 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/MemberCouponServiceImpl.java @@ -55,7 +55,7 @@ public class MemberCouponServiceImpl extends ServiceImpl= coupon.getPublishNum()) { + if (coupon.getPublishNum() != 0 && coupon.getReceivedNum() >= coupon.getPublishNum()) { throw new ServiceException("优惠券剩余领取数量不足"); } if (haveCoupons >= coupon.getCouponLimitNum()) { From 9c574ad9b75711f50ac8ac2abedf6c6f30110be2 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Thu, 24 Jun 2021 16:03:49 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=AA=92=E4=BD=93=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/lili/modules/broadcast/util/WechatMediaUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java index ad6cef2b..70cb60a4 100644 --- a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java +++ b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java @@ -98,6 +98,7 @@ public class WechatMediaUtil { log.error("微信媒体上传失败",e); } JSONObject jsonObject=new JSONObject(resultStr.toString()); + log.info("微信媒体上传:"+jsonObject.toString()); return jsonObject.get("media_id").toString(); } /** From 30846819d869584297fbedf4f2dc61d86a38da22 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Thu, 24 Jun 2021 17:19:17 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=BA=BF=E4=B8=8A?= =?UTF-8?q?=E3=80=81=E6=9C=AC=E5=9C=B0=E5=BC=80=E5=8F=91=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E5=BE=AE=E4=BF=A1token=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../broadcast/util/WechatLivePlayerUtil.java | 123 ++++++++---------- .../broadcast/util/WechatMediaUtil.java | 53 +++++--- .../message/util/WechatAccessTokenUtil.java | 7 + 3 files changed, 94 insertions(+), 89 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatLivePlayerUtil.java b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatLivePlayerUtil.java index 32f80ed6..d6a4fded 100644 --- a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatLivePlayerUtil.java +++ b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatLivePlayerUtil.java @@ -38,18 +38,11 @@ public class WechatLivePlayerUtil { * @return 房间ID */ public Map create(Studio studio) throws Exception { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token=" + token; + String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token="; //添加直播间 - Map map = this.mockRoom(token, studio); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序直播间创建结果:" + content); - if (!json.getStr("errcode").equals("0")) { - throw new ServiceException(json.getStr("errmsg")); - } + Map map = this.mockRoom(studio); + JSONObject json = this.doPostWithJson(url, map); Map roomMap = new HashMap<>(); roomMap.put("roomId", json.getStr("roomId")); roomMap.put("qrcodeUrl", json.getStr("qrcode_url")); @@ -63,20 +56,13 @@ public class WechatLivePlayerUtil { * @return 房间ID */ public boolean editRoom(Studio studio) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/editroom?access_token=" + token; + String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/editroom?access_token="; //修改直播间 - Map map = this.mockRoom(token, studio); + Map map = this.mockRoom(studio); map.put("id", studio.getRoomId().toString()); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序直播间修改结果:" + content); - if (!json.getStr("errcode").equals("0")) { - throw new ServiceException(json.getStr("errmsg")); - } + this.doPostWithJson(url, map); return true; } @@ -88,10 +74,8 @@ public class WechatLivePlayerUtil { * @return 回放地址 */ public String getLiveInfo(Integer roomId) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=" + token; + String url = "https://api.weixin.qq.com/wxa/business/getliveinfo?access_token="; Map map = new HashMap<>(); //获取回放 map.put("action", "get_replay"); @@ -101,10 +85,7 @@ public class WechatLivePlayerUtil { map.put("start", "0"); //每次拉取的数量,建议100以内 map.put("limit", "1"); - - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序获取信息:" + content); + JSONObject json = this.doPostWithJson(url, map); //TODO get media_url return json.getStr("live_replay"); } @@ -117,22 +98,15 @@ public class WechatLivePlayerUtil { * @return 操作结果 */ public Boolean pushGoods(Integer roomId, Integer goodsId) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods?access_token=" + token; + String url = "https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods?access_token="; Map map = new HashMap<>(); //直播间回放 Integer[] ids = {goodsId}; map.put("ids", ids); //商品ID map.put("roomId", roomId); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("直播间导入商品:" + content); - if (!json.getStr("errcode").equals("0")) { - throw new ServiceException(json.getStr("errmsg")); - } + this.doPostWithJson(url, map); return true; } @@ -144,22 +118,15 @@ public class WechatLivePlayerUtil { * @return 操作结果 */ public Boolean goodsDeleteInRoom(Integer roomId, Integer goodsId) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom?access_token=" + token; + String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/deleteInRoom?access_token="; Map map = new HashMap<>(); //直播间回放 map.put("goodsId", goodsId); //商品ID map.put("roomId", roomId); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序直播间删除商品:" + content); - if(json.getStr("errcode").equals("0")){ - return true; - } - throw new ServiceException(json.getStr("errmsg")); + this.doPostWithJson(url, map); + return true; } @@ -170,10 +137,8 @@ public class WechatLivePlayerUtil { * @return 添加结果 */ public JSONObject addGoods(Commodity commodity) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/add?access_token=" + token; + String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/add?access_token="; //商品名称,最长14个汉字 if (commodity.getName().length() > 14) { @@ -183,14 +148,11 @@ public class WechatLivePlayerUtil { //新建微信商品DTO GoodsInfo goodsInfo = new GoodsInfo(commodity); //上传微信临时图片 - goodsInfo.setCoverImgUrl(wechatMediaUtil.uploadMedia(token, "image", commodity.getGoodsImage())); + goodsInfo.setCoverImgUrl(wechatMediaUtil.uploadMedia("image", commodity.getGoodsImage())); Map map = new HashMap<>(); //调用新增直播商品接口 map.put("goodsInfo", goodsInfo); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序添加直播商品结果:" + content); - return json; + return this.doPostWithJson(url, map); } /** @@ -200,16 +162,11 @@ public class WechatLivePlayerUtil { * @return 删除结果 */ public JSONObject deleteGoods(String goodsId) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token=" + token; + String url = "https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token="; Map map = new HashMap<>(); map.put("goodsId", goodsId); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序删除直播商品结果:" + content); - return json; + return this.doPostWithJson(url, map); } /** @@ -219,26 +176,48 @@ public class WechatLivePlayerUtil { * @return 删除结果 */ public JSONObject getGoodsWareHouse(List goodsIdList) { - //获取token - String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); //发送url - String url = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse?access_token=" + token; + String url = "https://api.weixin.qq.com/wxa/business/getgoodswarehouse?access_token="; Map map = new HashMap<>(); map.put("goods_ids", goodsIdList); - String content = HttpUtils.doPostWithJson(url, map); - JSONObject json = new JSONObject(content); - log.info("微信小程序查询直播商品结果:" + content); - return json; + return this.doPostWithJson(url, map); } - private Map mockRoom(String token, Studio studio) { + /** + * 请求微信接口 + * @param url 链接 + * @param map 参数 + * @return 返回内容 + */ + private JSONObject doPostWithJson(String url, Map map) { + //获取token + String token = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); + //请求链接添加token + url+=token; + //发起请求 + String content = HttpUtils.doPostWithJson(url, map); + //记录请求结果 + log.info("微信小程序请求结果:" + content); + //获取请求内容,如果token过期则重新获取,如果出错则抛出错误 + JSONObject jsonObject = new JSONObject(content); + if (jsonObject.get("errcode").equals("0")) { + return jsonObject; + } else if (jsonObject.get("errcode").equals("40001")) { + wechatAccessTokenUtil.removeAccessToken(ClientTypeEnum.WECHAT_MP); + return this.doPostWithJson(url, map); + } else { + throw new ServiceException(jsonObject.get("errmsg").toString()); + } + } + + private Map mockRoom(Studio studio) { Map map = new HashMap<>(); //背景图 - map.put("coverImg", wechatMediaUtil.uploadMedia(token, "image", studio.getCoverImg())); + map.put("coverImg", wechatMediaUtil.uploadMedia("image", studio.getCoverImg())); //分享图 - map.put("shareImg", wechatMediaUtil.uploadMedia(token, "image", studio.getShareImg())); + map.put("shareImg", wechatMediaUtil.uploadMedia("image", studio.getShareImg())); //购物直播频道封面图 - map.put("feedsImg", wechatMediaUtil.uploadMedia(token, "image", studio.getFeedsImg())); + map.put("feedsImg", wechatMediaUtil.uploadMedia("image", studio.getFeedsImg())); //直播间名字 map.put("name", studio.getName()); //直播计划开始时间 diff --git a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java index 70cb60a4..792f24ad 100644 --- a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java +++ b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java @@ -1,7 +1,11 @@ package cn.lili.modules.broadcast.util; import cn.hutool.json.JSONObject; +import cn.lili.common.exception.ServiceException; +import cn.lili.modules.base.entity.enums.ClientTypeEnum; +import cn.lili.modules.message.util.WechatAccessTokenUtil; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.io.*; @@ -18,14 +22,18 @@ import java.util.Date; @Slf4j @Component public class WechatMediaUtil { + @Autowired + private WechatAccessTokenUtil wechatAccessTokenUtil; /** * 上传多媒体数据到微信服务器 - * @param accessToken 从微信获取到的access_token + * * @param mediaFileUrl 来自网络上面的媒体文件地址 * @return */ - public String uploadMedia(String accessToken, String type, String mediaFileUrl) { + public String uploadMedia(String type, String mediaFileUrl) { + //获取token + String accessToken = wechatAccessTokenUtil.cgiAccessToken(ClientTypeEnum.WECHAT_MP); /* * 上传媒体文件到微信服务器需要请求的地址 */ @@ -38,21 +46,21 @@ public class WechatMediaUtil { try { String boundary = "----WebKitFormBoundaryOYXo8heIv9pgpGjT"; URL url = new URL(mediaStr); - HttpURLConnection urlConn = (HttpURLConnection)url.openConnection(); + HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); //让输入输出流开启 urlConn.setDoInput(true); urlConn.setDoOutput(true); //使用post方式请求的时候必须关闭缓存 urlConn.setUseCaches(false); //设置请求头的Content-Type属性 - urlConn.setRequestProperty("Content-Type", "multipart/form-data; boundary="+boundary); + urlConn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); urlConn.setRequestMethod("POST"); //获取输出流,使用输出流拼接请求体 OutputStream out = urlConn.getOutputStream(); //读取文件的数据,构建一个GET请求,然后读取指定地址中的数据 mediaUrl = new URL(mediaFileUrl); - HttpURLConnection mediaConn = (HttpURLConnection)mediaUrl.openConnection(); + HttpURLConnection mediaConn = (HttpURLConnection) mediaUrl.openConnection(); //设置请求方式 mediaConn.setRequestMethod("GET"); //设置可以打开输入流 @@ -68,15 +76,15 @@ public class WechatMediaUtil { byte[] bytes = new byte[1024]; int size = 0; //使用outputStream流输出信息到请求体当中去 - out.write(("--"+boundary+"\r\n").getBytes()); + out.write(("--" + boundary + "\r\n").getBytes()); out.write(("Content-Disposition: form-data; name=\"media\";\r\n" - + "filename=\""+(new Date().getTime())+fileExt+"\"\r\n" - + "Content-Type: "+contentType+"\r\n\r\n").getBytes()); - while( (size = bufferedIn.read(bytes)) != -1) { + + "filename=\"" + (new Date().getTime()) + fileExt + "\"\r\n" + + "Content-Type: " + contentType + "\r\n\r\n").getBytes()); + while ((size = bufferedIn.read(bytes)) != -1) { out.write(bytes, 0, size); } //切记,这里的换行符不能少,否则将会报41005错误 - out.write(("\r\n--"+boundary+"--\r\n").getBytes()); + out.write(("\r\n--" + boundary + "--\r\n").getBytes()); bufferedIn.close(); in.close(); @@ -87,28 +95,39 @@ public class WechatMediaUtil { BufferedReader bufferedReader = new BufferedReader(reader); String tempStr = null; resultStr = new StringBuffer(); - while((tempStr = bufferedReader.readLine()) != null) { + while ((tempStr = bufferedReader.readLine()) != null) { resultStr.append(tempStr); } bufferedReader.close(); reader.close(); resultIn.close(); urlConn.disconnect(); - } catch (Exception e) { - log.error("微信媒体上传失败",e); + } catch (Exception e) { + log.error("微信媒体上传失败", e); } - JSONObject jsonObject=new JSONObject(resultStr.toString()); - log.info("微信媒体上传:"+jsonObject.toString()); - return jsonObject.get("media_id").toString(); + JSONObject jsonObject = new JSONObject(resultStr.toString()); + log.info("微信媒体上传:" + jsonObject.toString()); + //判断是否传递成功,如果token过期则重新获取 + if (jsonObject.get("errcode").equals("0")) { + return jsonObject.get("media_id").toString(); + } else if (jsonObject.get("errcode").equals("40001")) { + wechatAccessTokenUtil.removeAccessToken(ClientTypeEnum.WECHAT_MP); + return this.uploadMedia(type, mediaFileUrl); + } else { + throw new ServiceException(jsonObject.get("errmsg").toString()); + } + } + /** * 通过传过来的contentType判断是哪一种类型 + * * @param contentType 获取来自连接的contentType * @return */ public String judgeType(String contentType) { String fileExt = ""; - switch (contentType){ + switch (contentType) { case "image/png": fileExt = ".png"; break; diff --git a/framework/src/main/java/cn/lili/modules/message/util/WechatAccessTokenUtil.java b/framework/src/main/java/cn/lili/modules/message/util/WechatAccessTokenUtil.java index 26ca19e2..0ec1b8e5 100644 --- a/framework/src/main/java/cn/lili/modules/message/util/WechatAccessTokenUtil.java +++ b/framework/src/main/java/cn/lili/modules/message/util/WechatAccessTokenUtil.java @@ -110,5 +110,12 @@ public class WechatAccessTokenUtil { } + /** + * 清除 token + * @param clientTypeEnum + */ + public void removeAccessToken(ClientTypeEnum clientTypeEnum) { + cache.remove(CachePrefix.WECHAT_CGI_ACCESS_TOKEN.getPrefix() + clientTypeEnum.name()); + } } \ No newline at end of file From 83367ca96d19bec303ab0623ef19f28728e03ab4 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Thu, 24 Jun 2021 17:30:03 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=AA=92=E4=BD=93=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/modules/broadcast/util/WechatMediaUtil.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java index 792f24ad..768d6b53 100644 --- a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java +++ b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java @@ -108,13 +108,13 @@ public class WechatMediaUtil { JSONObject jsonObject = new JSONObject(resultStr.toString()); log.info("微信媒体上传:" + jsonObject.toString()); //判断是否传递成功,如果token过期则重新获取 - if (jsonObject.get("errcode").equals("0")) { - return jsonObject.get("media_id").toString(); - } else if (jsonObject.get("errcode").equals("40001")) { + if (jsonObject.get("errcode").equals("40001")) { wechatAccessTokenUtil.removeAccessToken(ClientTypeEnum.WECHAT_MP); return this.uploadMedia(type, mediaFileUrl); - } else { + } else if (jsonObject.get("errcode")!=null) { throw new ServiceException(jsonObject.get("errmsg").toString()); + } else { + return jsonObject.get("media_id").toString(); } } From 4fd8e4ecef391ffb7f86592a973399c0e6078f92 Mon Sep 17 00:00:00 2001 From: lifenlong Date: Thu, 24 Jun 2021 18:17:16 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=99=9A=E6=8B=9F?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=94=AE=E5=90=8E=E7=B1=BB=E5=9E=8B=E5=8F=AA?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=80=80=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/lili/event/impl/VerificationOrderExecute.java | 12 +++++++++++- .../lili/modules/broadcast/util/WechatMediaUtil.java | 4 ++-- .../order/order/entity/vo/AfterSaleApplyVO.java | 8 ++++++++ .../order/serviceimpl/AfterSaleServiceImpl.java | 9 +++++++++ .../order/order/serviceimpl/OrderServiceImpl.java | 9 ++------- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/consumer/src/main/java/cn/lili/event/impl/VerificationOrderExecute.java b/consumer/src/main/java/cn/lili/event/impl/VerificationOrderExecute.java index 95e2e3a8..0b696158 100644 --- a/consumer/src/main/java/cn/lili/event/impl/VerificationOrderExecute.java +++ b/consumer/src/main/java/cn/lili/event/impl/VerificationOrderExecute.java @@ -4,11 +4,16 @@ import cn.hutool.core.util.RandomUtil; import cn.lili.common.utils.CommonUtil; import cn.lili.event.OrderStatusChangeEvent; import cn.lili.modules.order.order.entity.dos.Order; +import cn.lili.modules.order.order.entity.dos.OrderItem; import cn.lili.modules.order.order.entity.dto.OrderMessage; +import cn.lili.modules.order.order.entity.enums.OrderComplaintStatusEnum; +import cn.lili.modules.order.order.entity.enums.OrderItemAfterSaleStatusEnum; import cn.lili.modules.order.order.entity.enums.OrderStatusEnum; +import cn.lili.modules.order.order.service.OrderItemService; import cn.lili.modules.order.order.service.OrderService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -23,7 +28,8 @@ public class VerificationOrderExecute implements OrderStatusChangeEvent { @Autowired private OrderService orderService; - + @Autowired + private OrderItemService orderItemService; @Override public void orderChange(OrderMessage orderMessage) { //订单状态为待核验,添加订单添加核验码 @@ -36,6 +42,10 @@ public class VerificationOrderExecute implements OrderStatusChangeEvent { orderService.update(new LambdaUpdateWrapper() .set(Order::getVerificationCode, code) .eq(Order::getSn, orderMessage.getOrderSn())); + //修改虚拟订单货物可以进行售后、投诉 + orderItemService.update(new LambdaUpdateWrapper().eq(OrderItem::getOrderSn, orderMessage.getOrderSn()) + .set(OrderItem::getAfterSaleStatus, OrderItemAfterSaleStatusEnum.NOT_APPLIED) + .set(OrderItem::getCommentStatus, OrderComplaintStatusEnum.NO_APPLY)); } } diff --git a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java index 768d6b53..eb885cb1 100644 --- a/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java +++ b/framework/src/main/java/cn/lili/modules/broadcast/util/WechatMediaUtil.java @@ -108,10 +108,10 @@ public class WechatMediaUtil { JSONObject jsonObject = new JSONObject(resultStr.toString()); log.info("微信媒体上传:" + jsonObject.toString()); //判断是否传递成功,如果token过期则重新获取 - if (jsonObject.get("errcode").equals("40001")) { + if (jsonObject.get("errcode") != null && jsonObject.get("errcode").equals("40001")) { wechatAccessTokenUtil.removeAccessToken(ClientTypeEnum.WECHAT_MP); return this.uploadMedia(type, mediaFileUrl); - } else if (jsonObject.get("errcode")!=null) { + } else if (jsonObject.get("errcode") != null) { throw new ServiceException(jsonObject.get("errmsg").toString()); } else { return jsonObject.get("media_id").toString(); diff --git a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AfterSaleApplyVO.java b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AfterSaleApplyVO.java index 5259e528..847e2ca0 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AfterSaleApplyVO.java +++ b/framework/src/main/java/cn/lili/modules/order/order/entity/vo/AfterSaleApplyVO.java @@ -47,4 +47,12 @@ public class AfterSaleApplyVO { */ @ApiModelProperty(value = "账号类型", allowableValues = "ALIPAY,WECHATPAY,MEMBERWALLET,BANKTRANSFER") private String accountType; + + @ApiModelProperty(value = "是否支持退货") + private boolean returnGoods; + + @ApiModelProperty(value = "是否支持退款") + private boolean returnMoney; + + } diff --git a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/AfterSaleServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/AfterSaleServiceImpl.java index 2df123ac..4c4e44a5 100644 --- a/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/AfterSaleServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/order/serviceimpl/AfterSaleServiceImpl.java @@ -20,6 +20,7 @@ import cn.lili.modules.order.order.entity.dos.OrderItem; import cn.lili.modules.order.order.entity.dto.AfterSaleDTO; import cn.lili.modules.order.order.entity.enums.OrderItemAfterSaleStatusEnum; import cn.lili.modules.order.order.entity.enums.OrderStatusEnum; +import cn.lili.modules.order.order.entity.enums.OrderTypeEnum; import cn.lili.modules.order.order.entity.enums.PayStatusEnum; import cn.lili.modules.order.order.entity.vo.AfterSaleApplyVO; import cn.lili.modules.order.order.entity.vo.AfterSaleSearchParams; @@ -128,6 +129,14 @@ public class AfterSaleServiceImpl extends ServiceImpl implements //检测虚拟订单信息 checkVerificationOrder(order, verificationCode); order.setOrderStatus(OrderStatusEnum.COMPLETED.name()); - //修改订单信息 - this.updateById(order); - //发送订单完成消息 - OrderMessage orderMessage = new OrderMessage(); - orderMessage.setNewStatus(OrderStatusEnum.COMPLETED); - orderMessage.setOrderSn(order.getSn()); - this.sendUpdateStatusMessage(orderMessage); + //订单完成 + this.complete(orderSn); return order; }