diff --git a/core/common/src/main/java/com/qihang/common/mq/MqType.java b/core/common/src/main/java/com/qihang/common/mq/MqType.java index d41bbf6a..47331b0f 100644 --- a/core/common/src/main/java/com/qihang/common/mq/MqType.java +++ b/core/common/src/main/java/com/qihang/common/mq/MqType.java @@ -8,5 +8,5 @@ public class MqType { /** * 退款消息 */ - public static final int REFUND_MESSAGE = 1; + public static final int REFUND_MESSAGE = 2; } diff --git a/jd-api/src/main/java/com/qihang/jd/controller/GoodsApiController.java b/jd-api/src/main/java/com/qihang/jd/controller/GoodsApiController.java index d72641b4..1d781b02 100644 --- a/jd-api/src/main/java/com/qihang/jd/controller/GoodsApiController.java +++ b/jd-api/src/main/java/com/qihang/jd/controller/GoodsApiController.java @@ -25,9 +25,11 @@ import com.qihang.common.common.ResultVo; import com.qihang.common.enums.HttpStatus; import com.qihang.jd.domain.JdGoods; import com.qihang.jd.domain.JdGoodsSku; +import com.qihang.jd.domain.SysShopPullLogs; import com.qihang.jd.openApi.ApiCommon; import com.qihang.jd.openApi.PullRequest; import com.qihang.jd.service.JdGoodsService; +import com.qihang.jd.service.SysShopPullLogsService; import lombok.AllArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.RequestBody; @@ -36,6 +38,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; +import java.util.Date; import java.util.List; @RequestMapping("/goods") @@ -44,12 +47,16 @@ import java.util.List; public class GoodsApiController { private final ApiCommon apiCommon; private final JdGoodsService goodsService; + private final SysShopPullLogsService pullLogsService; + @RequestMapping(value = "/pull_list", method = RequestMethod.POST) public Object pullList(@RequestBody PullRequest params) throws Exception { if (params.getShopId() == null || params.getShopId() <= 0) { // return ApiResul new ApiResult(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id"); return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id"); } + Date currDateTime = new Date(); + long startTime = System.currentTimeMillis(); var checkResult = apiCommon.checkBefore(params.getShopId()); if (checkResult.getCode() != HttpStatus.SUCCESS) { return ApiResult.build(checkResult.getCode(), checkResult.getMsg(), checkResult.getData()); @@ -95,6 +102,7 @@ public class GoodsApiController { request.setPageNo(1); request.setPageSize(100); WareReadSearchWare4ValidResponse response=client.execute(request); + int successTotal = 0; if(response != null && response.getPage()!= null && response.getPage().getData()!=null){ for (var ware: response.getPage().getData()){ JdGoods jdGoods = new JdGoods(); @@ -115,10 +123,22 @@ public class GoodsApiController { } } jdGoods.setSkuList(skuList); - ResultVo integerResultVo = goodsService.saveGoods(params.getShopId(),jdGoods); + goodsService.saveGoods(params.getShopId(),jdGoods); + successTotal++; } + } + SysShopPullLogs logs = new SysShopPullLogs(); + logs.setShopId(params.getShopId()); + logs.setPullType("GOODS"); + logs.setPullWay("主动拉取"); + logs.setPullParams("{WareStatusValue:8,PageNo:1,PageSize:100}"); + logs.setPullResult("{successTotal:"+successTotal+"}"); + logs.setPullTime(currDateTime); + logs.setDuration(System.currentTimeMillis() - startTime); + pullLogsService.save(logs); + //https://open.jd.com/home/home/#/doc/api?apiCateId=48&apiId=1227&apiName=jingdong.sku.read.searchSkuList // SkuReadSearchSkuListRequest request1=new SkuReadSearchSkuListRequest(); diff --git a/jd-api/src/main/java/com/qihang/jd/controller/OrderApiController.java b/jd-api/src/main/java/com/qihang/jd/controller/OrderApiController.java index 9edfd32b..6a75d98a 100644 --- a/jd-api/src/main/java/com/qihang/jd/controller/OrderApiController.java +++ b/jd-api/src/main/java/com/qihang/jd/controller/OrderApiController.java @@ -6,19 +6,26 @@ import com.qihang.common.enums.EnumShopType; import com.qihang.common.enums.HttpStatus; import com.qihang.common.mq.MqType; import com.qihang.jd.domain.JdOrder; +import com.qihang.jd.domain.SysShopPullLasttime; +import com.qihang.jd.domain.SysShopPullLogs; import com.qihang.jd.openApi.ApiCommon; import com.qihang.jd.openApi.OrderApiHelper; import com.qihang.jd.openApi.PullRequest; import com.qihang.common.mq.MqMessage; import com.qihang.common.mq.MqUtils; import com.qihang.jd.service.JdOrderService; +import com.qihang.jd.service.SysShopPullLasttimeService; +import com.qihang.jd.service.SysShopPullLogsService; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.ArrayList; +import java.util.Date; import java.util.List; @RequestMapping("/order") @@ -29,16 +36,18 @@ public class OrderApiController { // private final RedisCache redisCache; private final MqUtils mqUtils; private final JdOrderService orderService; - + private final SysShopPullLasttimeService pullLasttimeService; + private final SysShopPullLogsService pullLogsService; @RequestMapping(value = "/pull_list", method = RequestMethod.POST) public Object pullList(@RequestBody PullRequest params) throws Exception { -// Object cacheObject = redisCache.getCacheObject("jdorder"); - if (params.getShopId() == null || params.getShopId() <= 0) { -// return ApiResul new ApiResult(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id"); return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id"); } + + Date currDateTime = new Date(); + long beginTime = System.currentTimeMillis(); + var checkResult = apiCommon.checkBefore(params.getShopId()); if (checkResult.getCode() != HttpStatus.SUCCESS) { return ApiResult.build(checkResult.getCode(), checkResult.getMsg(),checkResult.getData()); @@ -47,8 +56,24 @@ public class OrderApiController { String serverUrl = checkResult.getData().getServerUrl(); String appKey = checkResult.getData().getAppKey(); String appSecret = checkResult.getData().getAppSecret(); + + // 获取最后更新时间 + LocalDateTime startTime = null; + LocalDateTime endTime = null; + SysShopPullLasttime lasttime = pullLasttimeService.getLasttimeByShop(params.getShopId(), "ORDER"); + if(lasttime == null){ + endTime = LocalDateTime.now(); + startTime = endTime.minusDays(1); + }else{ + startTime = lasttime.getLasttime().minusHours(1);//取上次结束一个小时前 + endTime = startTime.plusDays(1);//取24小时 + if(endTime.isAfter(LocalDateTime.now())){ + endTime = LocalDateTime.now(); + } + } + //第一次获取 - ApiResult upResult = OrderApiHelper.pullOrder(1L,100L,serverUrl,appKey,appSecret,accessToken); + ApiResult upResult = OrderApiHelper.pullOrder(startTime,endTime,1L,100L,serverUrl,appKey,appSecret,accessToken); int insertSuccess = 0;//新增成功的订单 int totalError = 0; int hasExistOrder = 0;//已存在的订单数 @@ -67,6 +92,32 @@ public class OrderApiController { totalError++; } } + if(lasttime == null){ + // 新增 + SysShopPullLasttime insertLasttime = new SysShopPullLasttime(); + insertLasttime.setShopId(params.getShopId()); + insertLasttime.setCreateTime(new Date()); + insertLasttime.setLasttime(endTime); + insertLasttime.setPullType("ORDER"); + pullLasttimeService.save(insertLasttime); + + }else { + // 修改 + SysShopPullLasttime updateLasttime = new SysShopPullLasttime(); + updateLasttime.setId(lasttime.getId()); + updateLasttime.setUpdateTime(new Date()); + updateLasttime.setLasttime(endTime); + pullLasttimeService.updateById(updateLasttime); + } + SysShopPullLogs logs = new SysShopPullLogs(); + logs.setShopId(params.getShopId()); + logs.setPullType("ORDER"); + logs.setPullWay("主动拉取"); + logs.setPullParams("{startTime:"+startTime+",endTime:"+endTime+"}"); + logs.setPullResult("{insertSuccess:"+insertSuccess+",hasExistOrder:"+hasExistOrder+",totalError:"+totalError+"}"); + logs.setPullTime(currDateTime); + logs.setDuration(System.currentTimeMillis() - beginTime); + pullLogsService.save(logs); return upResult; } } diff --git a/jd-api/src/main/java/com/qihang/jd/controller/RefundApiController.java b/jd-api/src/main/java/com/qihang/jd/controller/RefundApiController.java index 1d2cfe38..1ed15c1b 100644 --- a/jd-api/src/main/java/com/qihang/jd/controller/RefundApiController.java +++ b/jd-api/src/main/java/com/qihang/jd/controller/RefundApiController.java @@ -5,26 +5,43 @@ import com.jd.open.api.sdk.JdClient; import com.jd.open.api.sdk.request.refundapply.PopAfsRefundapplyQuerylistRequest; import com.jd.open.api.sdk.response.refundapply.PopAfsRefundapplyQuerylistResponse; import com.qihang.common.common.ApiResult; +import com.qihang.common.common.ResultVoEnum; +import com.qihang.common.enums.EnumShopType; import com.qihang.common.enums.HttpStatus; +import com.qihang.common.mq.MqMessage; +import com.qihang.common.mq.MqType; +import com.qihang.common.mq.MqUtils; +import com.qihang.jd.domain.JdRefund; +import com.qihang.jd.domain.SysShopPullLogs; import com.qihang.jd.openApi.ApiCommon; import com.qihang.jd.openApi.PullRequest; +import com.qihang.jd.service.JdRefundService; +import com.qihang.jd.service.SysShopPullLogsService; import lombok.AllArgsConstructor; +import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import java.util.Date; + @RequestMapping("/refund") @RestController @AllArgsConstructor public class RefundApiController { private final ApiCommon apiCommon; + private final SysShopPullLogsService pullLogsService; + private final JdRefundService refundService; + private final MqUtils mqUtils; + @RequestMapping(value = "/pull_list", method = RequestMethod.POST) public Object pullList(@RequestBody PullRequest params) throws Exception { if (params.getShopId() == null || params.getShopId() <= 0) { -// return ApiResul new ApiResult(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id"); return ApiResult.build(HttpStatus.PARAMS_ERROR, "参数错误,没有店铺Id"); } + Date currDateTime = new Date(); + long beginTime = System.currentTimeMillis(); var checkResult = apiCommon.checkBefore(params.getShopId()); if (checkResult.getCode() != HttpStatus.SUCCESS) { return ApiResult.build(checkResult.getCode(), checkResult.getMsg(), checkResult.getData()); @@ -33,26 +50,47 @@ public class RefundApiController { String serverUrl = checkResult.getData().getServerUrl(); String appKey = checkResult.getData().getAppKey(); String appSecret = checkResult.getData().getAppSecret(); -// String accessToken = "8abd974c62c34778935b34b5952e6f68izdk"; -// String appKey="FB4CC3688E6F9065D4FF510A53BB60FF"; -// String appSecret="40e8c8b2427f4e6db8f4a39af27d719e"; - JdClient client = new DefaultJdClient(serverUrl, accessToken, appKey, appSecret); //https://open.jd.com/home/home/#/doc/api?apiCateId=71&apiId=307&apiName=jingdong.pop.afs.refundapply.querylist PopAfsRefundapplyQuerylistRequest request2=new PopAfsRefundapplyQuerylistRequest(); -// request2.setStatus("1"); -// request2.setId("111"); -// request2.setOrderId("1234"); -// request2.setBuyerId("abc"); -// request2.setBuyerName("abc"); -// request2.setApplyTimeStart("2023-12-01 16:11:40"); -// request2.setApplyTimeEnd("2023-12-31 16:11:40"); -// request2.setCheckTimeStart("2023-12-01 16:11:40"); -// request2.setCheckTimeEnd("2023-12-31 16:11:40"); request2.setPageIndex(1); request2.setPageSize(100); PopAfsRefundapplyQuerylistResponse response2=client.execute(request2); - System.out.println(request2); +// System.out.println(request2); + int hasExist = 0; + int insertSuccess = 0; + int totalError = 0; + if(response2 != null && response2.getRefundApplyResponse()!=null ){ + for (var item :response2.getRefundApplyResponse().getResults()){ + JdRefund refund = new JdRefund(); + BeanUtils.copyProperties(item,refund); + refund.setRefundId(item.getId()); + refund.setId(null); + refund.setShopId(params.getShopId()); + //插入订单数据 + var result = refundService.saveRefund(params.getShopId(), refund); + if (result.getCode() == ResultVoEnum.DataExist.getIndex()) { + //已经存在 + hasExist++; + mqUtils.sendApiMessage(MqMessage.build(EnumShopType.JD, MqType.REFUND_MESSAGE,item.getId())); + } else if (result.getCode() == ResultVoEnum.SUCCESS.getIndex()) { + insertSuccess++; + mqUtils.sendApiMessage(MqMessage.build(EnumShopType.JD,MqType.REFUND_MESSAGE,item.getId())); + } else { + totalError++; + } + } + } + + SysShopPullLogs logs = new SysShopPullLogs(); + logs.setShopId(params.getShopId()); + logs.setPullType("REFUND"); + logs.setPullWay("主动拉取"); + logs.setPullParams("{PageIndex:1,PageSize:100}"); + logs.setPullResult("{total:"+insertSuccess+",hasExist:"+hasExist+",totalError:"+totalError+"}"); + logs.setPullTime(currDateTime); + logs.setDuration(System.currentTimeMillis() - beginTime); + pullLogsService.save(logs); return response2; } } diff --git a/jd-api/src/main/java/com/qihang/jd/domain/SysShopPullLasttime.java b/jd-api/src/main/java/com/qihang/jd/domain/SysShopPullLasttime.java new file mode 100644 index 00000000..36459811 --- /dev/null +++ b/jd-api/src/main/java/com/qihang/jd/domain/SysShopPullLasttime.java @@ -0,0 +1,177 @@ +package com.qihang.jd.domain; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Date; + +/** + * 店铺更新最后时间记录 + * @TableName sys_shop_pull_lasttime + */ +public class SysShopPullLasttime implements Serializable { + /** + * + */ + private Integer id; + + /** + * 店铺id + */ + private Integer shopId; + + /** + * 类型(ORDER:订单,REFUND:退款) + */ + private Object pullType; + + /** + * 最后更新时间 + */ + private LocalDateTime lasttime; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + private static final long serialVersionUID = 1L; + + /** + * + */ + public Integer getId() { + return id; + } + + /** + * + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * 店铺id + */ + public Integer getShopId() { + return shopId; + } + + /** + * 店铺id + */ + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + /** + * 类型(ORDER:订单,REFUND:退款) + */ + public Object getPullType() { + return pullType; + } + + /** + * 类型(ORDER:订单,REFUND:退款) + */ + public void setPullType(Object pullType) { + this.pullType = pullType; + } + + /** + * 最后更新时间 + */ + public LocalDateTime getLasttime() { + return lasttime; + } + + /** + * 最后更新时间 + */ + public void setLasttime(LocalDateTime lasttime) { + this.lasttime = lasttime; + } + + /** + * 创建时间 + */ + public Date getCreateTime() { + return createTime; + } + + /** + * 创建时间 + */ + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + /** + * 更新时间 + */ + public Date getUpdateTime() { + return updateTime; + } + + /** + * 更新时间 + */ + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + SysShopPullLasttime other = (SysShopPullLasttime) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId())) + && (this.getPullType() == null ? other.getPullType() == null : this.getPullType().equals(other.getPullType())) + && (this.getLasttime() == null ? other.getLasttime() == null : this.getLasttime().equals(other.getLasttime())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode()); + result = prime * result + ((getPullType() == null) ? 0 : getPullType().hashCode()); + result = prime * result + ((getLasttime() == null) ? 0 : getLasttime().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", shopId=").append(shopId); + sb.append(", pullType=").append(pullType); + sb.append(", lasttime=").append(lasttime); + sb.append(", createTime=").append(createTime); + sb.append(", updateTime=").append(updateTime); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/jd-api/src/main/java/com/qihang/jd/domain/SysShopPullLogs.java b/jd-api/src/main/java/com/qihang/jd/domain/SysShopPullLogs.java new file mode 100644 index 00000000..9f23c1b5 --- /dev/null +++ b/jd-api/src/main/java/com/qihang/jd/domain/SysShopPullLogs.java @@ -0,0 +1,220 @@ +package com.qihang.jd.domain; + +import java.io.Serializable; +import java.util.Date; + +/** + * 更新日志表 + * @TableName sys_shop_pull_logs + */ +public class SysShopPullLogs implements Serializable { + /** + * 主键Id + */ + private Long id; + + /** + * 店铺id + */ + private Integer shopId; + + /** + * 类型(ORDER订单,GOODS商品,REFUN退款) + */ + private String pullType; + + /** + * 拉取方式(主动拉取、定时任务) + */ + private String pullWay; + + /** + * 拉取参数 + */ + private String pullParams; + + /** + * 拉取结果 + */ + private String pullResult; + + /** + * 拉取时间 + */ + private Date pullTime; + + /** + * 耗时(毫秒) + */ + private Long duration; + + private static final long serialVersionUID = 1L; + + /** + * 主键Id + */ + public Long getId() { + return id; + } + + /** + * 主键Id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * 店铺id + */ + public Integer getShopId() { + return shopId; + } + + /** + * 店铺id + */ + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + /** + * 类型(ORDER订单,GOODS商品,REFUN退款) + */ + public String getPullType() { + return pullType; + } + + /** + * 类型(ORDER订单,GOODS商品,REFUN退款) + */ + public void setPullType(String pullType) { + this.pullType = pullType; + } + + /** + * 拉取方式(主动拉取、定时任务) + */ + public String getPullWay() { + return pullWay; + } + + /** + * 拉取方式(主动拉取、定时任务) + */ + public void setPullWay(String pullWay) { + this.pullWay = pullWay; + } + + /** + * 拉取参数 + */ + public String getPullParams() { + return pullParams; + } + + /** + * 拉取参数 + */ + public void setPullParams(String pullParams) { + this.pullParams = pullParams; + } + + /** + * 拉取结果 + */ + public String getPullResult() { + return pullResult; + } + + /** + * 拉取结果 + */ + public void setPullResult(String pullResult) { + this.pullResult = pullResult; + } + + /** + * 拉取时间 + */ + public Date getPullTime() { + return pullTime; + } + + /** + * 拉取时间 + */ + public void setPullTime(Date pullTime) { + this.pullTime = pullTime; + } + + /** + * 耗时(毫秒) + */ + public Long getDuration() { + return duration; + } + + /** + * 耗时(毫秒) + */ + public void setDuration(Long duration) { + this.duration = duration; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + SysShopPullLogs other = (SysShopPullLogs) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId())) + && (this.getPullType() == null ? other.getPullType() == null : this.getPullType().equals(other.getPullType())) + && (this.getPullWay() == null ? other.getPullWay() == null : this.getPullWay().equals(other.getPullWay())) + && (this.getPullParams() == null ? other.getPullParams() == null : this.getPullParams().equals(other.getPullParams())) + && (this.getPullResult() == null ? other.getPullResult() == null : this.getPullResult().equals(other.getPullResult())) + && (this.getPullTime() == null ? other.getPullTime() == null : this.getPullTime().equals(other.getPullTime())) + && (this.getDuration() == null ? other.getDuration() == null : this.getDuration().equals(other.getDuration())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode()); + result = prime * result + ((getPullType() == null) ? 0 : getPullType().hashCode()); + result = prime * result + ((getPullWay() == null) ? 0 : getPullWay().hashCode()); + result = prime * result + ((getPullParams() == null) ? 0 : getPullParams().hashCode()); + result = prime * result + ((getPullResult() == null) ? 0 : getPullResult().hashCode()); + result = prime * result + ((getPullTime() == null) ? 0 : getPullTime().hashCode()); + result = prime * result + ((getDuration() == null) ? 0 : getDuration().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", shopId=").append(shopId); + sb.append(", pullType=").append(pullType); + sb.append(", pullWay=").append(pullWay); + sb.append(", pullParams=").append(pullParams); + sb.append(", pullResult=").append(pullResult); + sb.append(", pullTime=").append(pullTime); + sb.append(", duration=").append(duration); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/jd-api/src/main/java/com/qihang/jd/mapper/SysShopPullLasttimeMapper.java b/jd-api/src/main/java/com/qihang/jd/mapper/SysShopPullLasttimeMapper.java new file mode 100644 index 00000000..c74b0a9f --- /dev/null +++ b/jd-api/src/main/java/com/qihang/jd/mapper/SysShopPullLasttimeMapper.java @@ -0,0 +1,18 @@ +package com.qihang.jd.mapper; + +import com.qihang.jd.domain.SysShopPullLasttime; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author qilip +* @description 针对表【sys_shop_pull_lasttime(店铺更新最后时间记录)】的数据库操作Mapper +* @createDate 2024-03-10 12:15:10 +* @Entity com.qihang.jd.domain.SysShopPullLasttime +*/ +public interface SysShopPullLasttimeMapper extends BaseMapper { + +} + + + + diff --git a/jd-api/src/main/java/com/qihang/jd/mapper/SysShopPullLogsMapper.java b/jd-api/src/main/java/com/qihang/jd/mapper/SysShopPullLogsMapper.java new file mode 100644 index 00000000..77a21cd5 --- /dev/null +++ b/jd-api/src/main/java/com/qihang/jd/mapper/SysShopPullLogsMapper.java @@ -0,0 +1,18 @@ +package com.qihang.jd.mapper; + +import com.qihang.jd.domain.SysShopPullLogs; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author qilip +* @description 针对表【sys_shop_pull_logs(更新日志表)】的数据库操作Mapper +* @createDate 2024-03-10 12:04:46 +* @Entity com.qihang.jd.domain.SysShopPullLogs +*/ +public interface SysShopPullLogsMapper extends BaseMapper { + +} + + + + diff --git a/jd-api/src/main/java/com/qihang/jd/openApi/OrderApiHelper.java b/jd-api/src/main/java/com/qihang/jd/openApi/OrderApiHelper.java index 92288542..8af3e4f7 100644 --- a/jd-api/src/main/java/com/qihang/jd/openApi/OrderApiHelper.java +++ b/jd-api/src/main/java/com/qihang/jd/openApi/OrderApiHelper.java @@ -15,6 +15,7 @@ import org.springframework.util.StringUtils; import java.time.LocalDateTime; import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Date; @@ -33,12 +34,16 @@ public class OrderApiHelper { * @param accessToken * @return */ - public static ApiResult pullOrder(Long pageNo, Long pageSize, String serverUrl, String appKey, String appSecret, String accessToken) throws Exception { - log.info("=======开始全量拉取订单{}=========",LocalDateTime.now()); + public static ApiResult pullOrder(LocalDateTime startTime,LocalDateTime endTime,Long pageNo, Long pageSize, String serverUrl, String appKey, String appSecret, String accessToken) throws Exception { + String startTimeStr = startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + String endTimeStr = endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + + log.info("=======开始全量JD拉取订单{},参数日期:{}-{}=========",LocalDateTime.now(),startTimeStr,endTimeStr); + JdClient client=new DefaultJdClient(serverUrl,accessToken,appKey,appSecret); PopOrderEnSearchRequest request =new PopOrderEnSearchRequest(); - request.setStartDate("2024-02-06 00:20:35"); - request.setEndDate("2024-03-05 15:20:35"); + request.setStartDate(startTimeStr); + request.setEndDate(endTimeStr); // request.setOrderState("WAIT_SELLER_STOCK_OUT,WAIT_GOODS_RECEIVE_CONFIRM,WAIT_SELLER_DELIVERY,PAUSE,FINISHED_L,TRADE_CANCELED,LOCKED,POP_ORDER_PAUSE"); // request.setOrderState(""); request.setOrderState("ALL"); diff --git a/jd-api/src/main/java/com/qihang/jd/service/JdRefundService.java b/jd-api/src/main/java/com/qihang/jd/service/JdRefundService.java index e63ea3a0..b80989ee 100644 --- a/jd-api/src/main/java/com/qihang/jd/service/JdRefundService.java +++ b/jd-api/src/main/java/com/qihang/jd/service/JdRefundService.java @@ -1,5 +1,7 @@ package com.qihang.jd.service; +import com.qihang.common.common.ResultVo; +import com.qihang.jd.domain.JdOrder; import com.qihang.jd.domain.JdRefund; import com.baomidou.mybatisplus.extension.service.IService; @@ -9,5 +11,5 @@ import com.baomidou.mybatisplus.extension.service.IService; * @createDate 2024-03-09 11:29:59 */ public interface JdRefundService extends IService { - + ResultVo saveRefund(Integer shopId, JdRefund refund); } diff --git a/jd-api/src/main/java/com/qihang/jd/service/SysShopPullLasttimeService.java b/jd-api/src/main/java/com/qihang/jd/service/SysShopPullLasttimeService.java new file mode 100644 index 00000000..be0fd038 --- /dev/null +++ b/jd-api/src/main/java/com/qihang/jd/service/SysShopPullLasttimeService.java @@ -0,0 +1,13 @@ +package com.qihang.jd.service; + +import com.qihang.jd.domain.SysShopPullLasttime; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author qilip +* @description 针对表【sys_shop_pull_lasttime(店铺更新最后时间记录)】的数据库操作Service +* @createDate 2024-03-10 12:15:10 +*/ +public interface SysShopPullLasttimeService extends IService { + SysShopPullLasttime getLasttimeByShop(Integer shopId,String pullType); +} diff --git a/jd-api/src/main/java/com/qihang/jd/service/SysShopPullLogsService.java b/jd-api/src/main/java/com/qihang/jd/service/SysShopPullLogsService.java new file mode 100644 index 00000000..d63e59f2 --- /dev/null +++ b/jd-api/src/main/java/com/qihang/jd/service/SysShopPullLogsService.java @@ -0,0 +1,13 @@ +package com.qihang.jd.service; + +import com.qihang.jd.domain.SysShopPullLogs; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author qilip +* @description 针对表【sys_shop_pull_logs(更新日志表)】的数据库操作Service +* @createDate 2024-03-10 12:04:46 +*/ +public interface SysShopPullLogsService extends IService { + +} diff --git a/jd-api/src/main/java/com/qihang/jd/service/impl/JdRefundServiceImpl.java b/jd-api/src/main/java/com/qihang/jd/service/impl/JdRefundServiceImpl.java index 86f44089..144a68e7 100644 --- a/jd-api/src/main/java/com/qihang/jd/service/impl/JdRefundServiceImpl.java +++ b/jd-api/src/main/java/com/qihang/jd/service/impl/JdRefundServiceImpl.java @@ -1,20 +1,58 @@ package com.qihang.jd.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.qihang.common.common.ResultVo; +import com.qihang.common.common.ResultVoEnum; +import com.qihang.jd.domain.JdOrder; +import com.qihang.jd.domain.JdOrderItem; import com.qihang.jd.domain.JdRefund; import com.qihang.jd.service.JdRefundService; import com.qihang.jd.mapper.JdRefundMapper; +import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; + +import java.util.Date; +import java.util.List; /** * @author qilip * @description 针对表【jd_refund】的数据库操作Service实现 * @createDate 2024-03-09 11:29:59 */ +@AllArgsConstructor @Service public class JdRefundServiceImpl extends ServiceImpl implements JdRefundService{ + private final JdRefundMapper mapper; + @Transactional + @Override + public ResultVo saveRefund(Integer shopId, JdRefund refund) { + try { + List jdRefunds = mapper.selectList(new LambdaQueryWrapper().eq(JdRefund::getRefundId, refund.getRefundId())); + if (jdRefunds != null && jdRefunds.size() > 0) { + // 存在,修改 + JdRefund update = new JdRefund(); + update.setId(jdRefunds.get(0).getId()); + update.setCheckTime(refund.getCheckTime()); + update.setCheckUsername(refund.getCheckUsername()); + update.setStatus(refund.getStatus()); + mapper.updateById(update); + return new ResultVo<>(ResultVoEnum.DataExist, "退款已经存在,更新成功"); + } else { + // 不存在,新增 + refund.setShopId(shopId); + mapper.insert(refund); + return new ResultVo<>(ResultVoEnum.SUCCESS, "SUCCESS"); + } + } catch (Exception e) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return new ResultVo<>(ResultVoEnum.SystemException, "系统异常:" + e.getMessage()); + } + } } diff --git a/jd-api/src/main/java/com/qihang/jd/service/impl/SysShopPullLasttimeServiceImpl.java b/jd-api/src/main/java/com/qihang/jd/service/impl/SysShopPullLasttimeServiceImpl.java new file mode 100644 index 00000000..8407fa7b --- /dev/null +++ b/jd-api/src/main/java/com/qihang/jd/service/impl/SysShopPullLasttimeServiceImpl.java @@ -0,0 +1,34 @@ +package com.qihang.jd.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.qihang.jd.domain.SysShopPullLasttime; +import com.qihang.jd.service.SysShopPullLasttimeService; +import com.qihang.jd.mapper.SysShopPullLasttimeMapper; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* @author qilip +* @description 针对表【sys_shop_pull_lasttime(店铺更新最后时间记录)】的数据库操作Service实现 +* @createDate 2024-03-10 12:15:10 +*/ +@AllArgsConstructor +@Service +public class SysShopPullLasttimeServiceImpl extends ServiceImpl + implements SysShopPullLasttimeService { + private final SysShopPullLasttimeMapper mapper; + + @Override + public SysShopPullLasttime getLasttimeByShop(Integer shopId, String pullType) { + List sysShopPullLasttimes = mapper.selectList(new LambdaQueryWrapper().eq(SysShopPullLasttime::getShopId, shopId).eq(SysShopPullLasttime::getPullType, pullType)); + if(sysShopPullLasttimes != null && !sysShopPullLasttimes.isEmpty()) return sysShopPullLasttimes.get(0); + else return null; + } +} + + + + diff --git a/jd-api/src/main/java/com/qihang/jd/service/impl/SysShopPullLogsServiceImpl.java b/jd-api/src/main/java/com/qihang/jd/service/impl/SysShopPullLogsServiceImpl.java new file mode 100644 index 00000000..7d485eaa --- /dev/null +++ b/jd-api/src/main/java/com/qihang/jd/service/impl/SysShopPullLogsServiceImpl.java @@ -0,0 +1,22 @@ +package com.qihang.jd.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.qihang.jd.domain.SysShopPullLogs; +import com.qihang.jd.service.SysShopPullLogsService; +import com.qihang.jd.mapper.SysShopPullLogsMapper; +import org.springframework.stereotype.Service; + +/** +* @author qilip +* @description 针对表【sys_shop_pull_logs(更新日志表)】的数据库操作Service实现 +* @createDate 2024-03-10 12:04:46 +*/ +@Service +public class SysShopPullLogsServiceImpl extends ServiceImpl + implements SysShopPullLogsService{ + +} + + + + diff --git a/jd-api/src/main/resources/mapper/SysShopPullLasttimeMapper.xml b/jd-api/src/main/resources/mapper/SysShopPullLasttimeMapper.xml new file mode 100644 index 00000000..b47b7f93 --- /dev/null +++ b/jd-api/src/main/resources/mapper/SysShopPullLasttimeMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + id,shop_id,pull_type, + lasttime,create_time,update_time + + diff --git a/jd-api/src/main/resources/mapper/SysShopPullLogsMapper.xml b/jd-api/src/main/resources/mapper/SysShopPullLogsMapper.xml new file mode 100644 index 00000000..be164326 --- /dev/null +++ b/jd-api/src/main/resources/mapper/SysShopPullLogsMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + id,shop_id,pull_type, + pull_way,pull_params,pull_result, + pull_time,duration + + diff --git a/sys-api/src/main/java/com/qihang/sys/api/domain/JdRefund.java b/sys-api/src/main/java/com/qihang/sys/api/domain/JdRefund.java new file mode 100644 index 00000000..5b315d72 --- /dev/null +++ b/sys-api/src/main/java/com/qihang/sys/api/domain/JdRefund.java @@ -0,0 +1,285 @@ +package com.qihang.sys.api.domain; + +import java.io.Serializable; + +/** + * + * @TableName jd_refund + */ +public class JdRefund implements Serializable { + /** + * + */ + private Long id; + + /** + * 店铺id + */ + private Integer shopId; + + /** + * 退款单id + */ + private String refundId; + + /** + * 客户帐号 + */ + private String buyerId; + + /** + * 客户姓名 + */ + private String buyerName; + + /** + * 审核日期 + */ + private String checkTime; + + /** + * 申请时间 + */ + private String applyTime; + + /** + * 退款金额 + */ + private String applyRefundSum; + + /** + * 审核状态: 0代表未审核, 1代表审核通过 2代表审核不通过 3代表京东财务审核通过;4代表京东财务审核不通过 + */ + private String status; + + /** + * 审核人 + */ + private String checkUsername; + + /** + * 订单号 + */ + private String orderId; + + private static final long serialVersionUID = 1L; + + /** + * + */ + public Long getId() { + return id; + } + + /** + * + */ + public void setId(Long id) { + this.id = id; + } + + /** + * 店铺id + */ + public Integer getShopId() { + return shopId; + } + + /** + * 店铺id + */ + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + /** + * 退款单id + */ + public String getRefundId() { + return refundId; + } + + /** + * 退款单id + */ + public void setRefundId(String refundId) { + this.refundId = refundId; + } + + /** + * 客户帐号 + */ + public String getBuyerId() { + return buyerId; + } + + /** + * 客户帐号 + */ + public void setBuyerId(String buyerId) { + this.buyerId = buyerId; + } + + /** + * 客户姓名 + */ + public String getBuyerName() { + return buyerName; + } + + /** + * 客户姓名 + */ + public void setBuyerName(String buyerName) { + this.buyerName = buyerName; + } + + /** + * 审核日期 + */ + public String getCheckTime() { + return checkTime; + } + + /** + * 审核日期 + */ + public void setCheckTime(String checkTime) { + this.checkTime = checkTime; + } + + /** + * 申请时间 + */ + public String getApplyTime() { + return applyTime; + } + + /** + * 申请时间 + */ + public void setApplyTime(String applyTime) { + this.applyTime = applyTime; + } + + /** + * 退款金额 + */ + public String getApplyRefundSum() { + return applyRefundSum; + } + + /** + * 退款金额 + */ + public void setApplyRefundSum(String applyRefundSum) { + this.applyRefundSum = applyRefundSum; + } + + /** + * 审核状态: 0代表未审核, 1代表审核通过 2代表审核不通过 3代表京东财务审核通过;4代表京东财务审核不通过 + */ + public String getStatus() { + return status; + } + + /** + * 审核状态: 0代表未审核, 1代表审核通过 2代表审核不通过 3代表京东财务审核通过;4代表京东财务审核不通过 + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * 审核人 + */ + public String getCheckUsername() { + return checkUsername; + } + + /** + * 审核人 + */ + public void setCheckUsername(String checkUsername) { + this.checkUsername = checkUsername; + } + + /** + * 订单号 + */ + public String getOrderId() { + return orderId; + } + + /** + * 订单号 + */ + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + JdRefund other = (JdRefund) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId())) + && (this.getRefundId() == null ? other.getRefundId() == null : this.getRefundId().equals(other.getRefundId())) + && (this.getBuyerId() == null ? other.getBuyerId() == null : this.getBuyerId().equals(other.getBuyerId())) + && (this.getBuyerName() == null ? other.getBuyerName() == null : this.getBuyerName().equals(other.getBuyerName())) + && (this.getCheckTime() == null ? other.getCheckTime() == null : this.getCheckTime().equals(other.getCheckTime())) + && (this.getApplyTime() == null ? other.getApplyTime() == null : this.getApplyTime().equals(other.getApplyTime())) + && (this.getApplyRefundSum() == null ? other.getApplyRefundSum() == null : this.getApplyRefundSum().equals(other.getApplyRefundSum())) + && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) + && (this.getCheckUsername() == null ? other.getCheckUsername() == null : this.getCheckUsername().equals(other.getCheckUsername())) + && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode()); + result = prime * result + ((getRefundId() == null) ? 0 : getRefundId().hashCode()); + result = prime * result + ((getBuyerId() == null) ? 0 : getBuyerId().hashCode()); + result = prime * result + ((getBuyerName() == null) ? 0 : getBuyerName().hashCode()); + result = prime * result + ((getCheckTime() == null) ? 0 : getCheckTime().hashCode()); + result = prime * result + ((getApplyTime() == null) ? 0 : getApplyTime().hashCode()); + result = prime * result + ((getApplyRefundSum() == null) ? 0 : getApplyRefundSum().hashCode()); + result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); + result = prime * result + ((getCheckUsername() == null) ? 0 : getCheckUsername().hashCode()); + result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", shopId=").append(shopId); + sb.append(", refundId=").append(refundId); + sb.append(", buyerId=").append(buyerId); + sb.append(", buyerName=").append(buyerName); + sb.append(", checkTime=").append(checkTime); + sb.append(", applyTime=").append(applyTime); + sb.append(", applyRefundSum=").append(applyRefundSum); + sb.append(", status=").append(status); + sb.append(", checkUsername=").append(checkUsername); + sb.append(", orderId=").append(orderId); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/sys-api/src/main/java/com/qihang/sys/api/domain/ORefund.java b/sys-api/src/main/java/com/qihang/sys/api/domain/ORefund.java new file mode 100644 index 00000000..19dff604 --- /dev/null +++ b/sys-api/src/main/java/com/qihang/sys/api/domain/ORefund.java @@ -0,0 +1,638 @@ +package com.qihang.sys.api.domain; + +import java.io.Serializable; +import java.util.Date; + +/** + * 退换货表 + * @TableName o_refund + */ +public class ORefund implements Serializable { + /** + * + */ + private Long id; + + /** + * 退货单号 + */ + private String refundNum; + + /** + * 退货类型(1退货2换货) + */ + private Integer refundType; + + /** + * 店铺id + */ + private Integer shopId; + + /** + * 店铺类型 + */ + private Integer shopType; + + /** + * 源订单号 + */ + private String orderNum; + + /** + * 子订单号或id + */ + private String orderItemNum; + + /** + * 源skuId + */ + private Long skuId; + + /** + * erp商品id + */ + private Long erpGoodsId; + + /** + * erp sku id + */ + private Long erpSkuId; + + /** + * sku编码 + */ + private String skuNum; + + /** + * 商品名称 + */ + private String goodsName; + + /** + * 商品sku + */ + private String goodsSku; + + /** + * 商品图片 + */ + private String goodsImage; + + /** + * 退货数量 + */ + private Long quantity; + + /** + * 退货物流公司 + */ + private String returnLogisticsCompany; + + /** + * 退货物流单号 + */ + private String returnLogisticsCode; + + /** + * 收货时间 + */ + private Date receiveTime; + + /** + * 备注 + */ + private String remark; + + /** + * 发货人 + */ + private String contactperson; + + /** + * 发货人手机号 + */ + private String mobile; + + /** + * 发货地址 + */ + private String address; + + /** + * 状态(0待发货1待收货2已收货3已完成) + */ + private Integer status; + + /** + * 订单创建时间 + */ + private Date createTime; + + /** + * 创建人 + */ + private String createBy; + + /** + * 更新时间 + */ + private Date updateTime; + + /** + * 更新人 + */ + private String updateBy; + + private static final long serialVersionUID = 1L; + + /** + * + */ + public Long getId() { + return id; + } + + /** + * + */ + public void setId(Long id) { + this.id = id; + } + + /** + * 退货单号 + */ + public String getRefundNum() { + return refundNum; + } + + /** + * 退货单号 + */ + public void setRefundNum(String refundNum) { + this.refundNum = refundNum; + } + + /** + * 退货类型(1退货2换货) + */ + public Integer getRefundType() { + return refundType; + } + + /** + * 退货类型(1退货2换货) + */ + public void setRefundType(Integer refundType) { + this.refundType = refundType; + } + + /** + * 店铺id + */ + public Integer getShopId() { + return shopId; + } + + /** + * 店铺id + */ + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + /** + * 店铺类型 + */ + public Integer getShopType() { + return shopType; + } + + /** + * 店铺类型 + */ + public void setShopType(Integer shopType) { + this.shopType = shopType; + } + + /** + * 源订单号 + */ + public String getOrderNum() { + return orderNum; + } + + /** + * 源订单号 + */ + public void setOrderNum(String orderNum) { + this.orderNum = orderNum; + } + + /** + * 子订单号或id + */ + public String getOrderItemNum() { + return orderItemNum; + } + + /** + * 子订单号或id + */ + public void setOrderItemNum(String orderItemNum) { + this.orderItemNum = orderItemNum; + } + + /** + * 源skuId + */ + public Long getSkuId() { + return skuId; + } + + /** + * 源skuId + */ + public void setSkuId(Long skuId) { + this.skuId = skuId; + } + + /** + * erp商品id + */ + public Long getErpGoodsId() { + return erpGoodsId; + } + + /** + * erp商品id + */ + public void setErpGoodsId(Long erpGoodsId) { + this.erpGoodsId = erpGoodsId; + } + + /** + * erp sku id + */ + public Long getErpSkuId() { + return erpSkuId; + } + + /** + * erp sku id + */ + public void setErpSkuId(Long erpSkuId) { + this.erpSkuId = erpSkuId; + } + + /** + * sku编码 + */ + public String getSkuNum() { + return skuNum; + } + + /** + * sku编码 + */ + public void setSkuNum(String skuNum) { + this.skuNum = skuNum; + } + + /** + * 商品名称 + */ + public String getGoodsName() { + return goodsName; + } + + /** + * 商品名称 + */ + public void setGoodsName(String goodsName) { + this.goodsName = goodsName; + } + + /** + * 商品sku + */ + public String getGoodsSku() { + return goodsSku; + } + + /** + * 商品sku + */ + public void setGoodsSku(String goodsSku) { + this.goodsSku = goodsSku; + } + + /** + * 商品图片 + */ + public String getGoodsImage() { + return goodsImage; + } + + /** + * 商品图片 + */ + public void setGoodsImage(String goodsImage) { + this.goodsImage = goodsImage; + } + + /** + * 退货数量 + */ + public Long getQuantity() { + return quantity; + } + + /** + * 退货数量 + */ + public void setQuantity(Long quantity) { + this.quantity = quantity; + } + + /** + * 退货物流公司 + */ + public String getReturnLogisticsCompany() { + return returnLogisticsCompany; + } + + /** + * 退货物流公司 + */ + public void setReturnLogisticsCompany(String returnLogisticsCompany) { + this.returnLogisticsCompany = returnLogisticsCompany; + } + + /** + * 退货物流单号 + */ + public String getReturnLogisticsCode() { + return returnLogisticsCode; + } + + /** + * 退货物流单号 + */ + public void setReturnLogisticsCode(String returnLogisticsCode) { + this.returnLogisticsCode = returnLogisticsCode; + } + + /** + * 收货时间 + */ + public Date getReceiveTime() { + return receiveTime; + } + + /** + * 收货时间 + */ + public void setReceiveTime(Date receiveTime) { + this.receiveTime = receiveTime; + } + + /** + * 备注 + */ + public String getRemark() { + return remark; + } + + /** + * 备注 + */ + public void setRemark(String remark) { + this.remark = remark; + } + + /** + * 发货人 + */ + public String getContactperson() { + return contactperson; + } + + /** + * 发货人 + */ + public void setContactperson(String contactperson) { + this.contactperson = contactperson; + } + + /** + * 发货人手机号 + */ + public String getMobile() { + return mobile; + } + + /** + * 发货人手机号 + */ + public void setMobile(String mobile) { + this.mobile = mobile; + } + + /** + * 发货地址 + */ + public String getAddress() { + return address; + } + + /** + * 发货地址 + */ + public void setAddress(String address) { + this.address = address; + } + + /** + * 状态(0待发货1待收货2已收货3已完成) + */ + public Integer getStatus() { + return status; + } + + /** + * 状态(0待发货1待收货2已收货3已完成) + */ + public void setStatus(Integer status) { + this.status = status; + } + + /** + * 订单创建时间 + */ + public Date getCreateTime() { + return createTime; + } + + /** + * 订单创建时间 + */ + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + /** + * 创建人 + */ + public String getCreateBy() { + return createBy; + } + + /** + * 创建人 + */ + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + /** + * 更新时间 + */ + public Date getUpdateTime() { + return updateTime; + } + + /** + * 更新时间 + */ + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + /** + * 更新人 + */ + public String getUpdateBy() { + return updateBy; + } + + /** + * 更新人 + */ + public void setUpdateBy(String updateBy) { + this.updateBy = updateBy; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (getClass() != that.getClass()) { + return false; + } + ORefund other = (ORefund) that; + return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) + && (this.getRefundNum() == null ? other.getRefundNum() == null : this.getRefundNum().equals(other.getRefundNum())) + && (this.getRefundType() == null ? other.getRefundType() == null : this.getRefundType().equals(other.getRefundType())) + && (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId())) + && (this.getShopType() == null ? other.getShopType() == null : this.getShopType().equals(other.getShopType())) + && (this.getOrderNum() == null ? other.getOrderNum() == null : this.getOrderNum().equals(other.getOrderNum())) + && (this.getOrderItemNum() == null ? other.getOrderItemNum() == null : this.getOrderItemNum().equals(other.getOrderItemNum())) + && (this.getSkuId() == null ? other.getSkuId() == null : this.getSkuId().equals(other.getSkuId())) + && (this.getErpGoodsId() == null ? other.getErpGoodsId() == null : this.getErpGoodsId().equals(other.getErpGoodsId())) + && (this.getErpSkuId() == null ? other.getErpSkuId() == null : this.getErpSkuId().equals(other.getErpSkuId())) + && (this.getSkuNum() == null ? other.getSkuNum() == null : this.getSkuNum().equals(other.getSkuNum())) + && (this.getGoodsName() == null ? other.getGoodsName() == null : this.getGoodsName().equals(other.getGoodsName())) + && (this.getGoodsSku() == null ? other.getGoodsSku() == null : this.getGoodsSku().equals(other.getGoodsSku())) + && (this.getGoodsImage() == null ? other.getGoodsImage() == null : this.getGoodsImage().equals(other.getGoodsImage())) + && (this.getQuantity() == null ? other.getQuantity() == null : this.getQuantity().equals(other.getQuantity())) + && (this.getReturnLogisticsCompany() == null ? other.getReturnLogisticsCompany() == null : this.getReturnLogisticsCompany().equals(other.getReturnLogisticsCompany())) + && (this.getReturnLogisticsCode() == null ? other.getReturnLogisticsCode() == null : this.getReturnLogisticsCode().equals(other.getReturnLogisticsCode())) + && (this.getReceiveTime() == null ? other.getReceiveTime() == null : this.getReceiveTime().equals(other.getReceiveTime())) + && (this.getRemark() == null ? other.getRemark() == null : this.getRemark().equals(other.getRemark())) + && (this.getContactperson() == null ? other.getContactperson() == null : this.getContactperson().equals(other.getContactperson())) + && (this.getMobile() == null ? other.getMobile() == null : this.getMobile().equals(other.getMobile())) + && (this.getAddress() == null ? other.getAddress() == null : this.getAddress().equals(other.getAddress())) + && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) + && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) + && (this.getCreateBy() == null ? other.getCreateBy() == null : this.getCreateBy().equals(other.getCreateBy())) + && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) + && (this.getUpdateBy() == null ? other.getUpdateBy() == null : this.getUpdateBy().equals(other.getUpdateBy())); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); + result = prime * result + ((getRefundNum() == null) ? 0 : getRefundNum().hashCode()); + result = prime * result + ((getRefundType() == null) ? 0 : getRefundType().hashCode()); + result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode()); + result = prime * result + ((getShopType() == null) ? 0 : getShopType().hashCode()); + result = prime * result + ((getOrderNum() == null) ? 0 : getOrderNum().hashCode()); + result = prime * result + ((getOrderItemNum() == null) ? 0 : getOrderItemNum().hashCode()); + result = prime * result + ((getSkuId() == null) ? 0 : getSkuId().hashCode()); + result = prime * result + ((getErpGoodsId() == null) ? 0 : getErpGoodsId().hashCode()); + result = prime * result + ((getErpSkuId() == null) ? 0 : getErpSkuId().hashCode()); + result = prime * result + ((getSkuNum() == null) ? 0 : getSkuNum().hashCode()); + result = prime * result + ((getGoodsName() == null) ? 0 : getGoodsName().hashCode()); + result = prime * result + ((getGoodsSku() == null) ? 0 : getGoodsSku().hashCode()); + result = prime * result + ((getGoodsImage() == null) ? 0 : getGoodsImage().hashCode()); + result = prime * result + ((getQuantity() == null) ? 0 : getQuantity().hashCode()); + result = prime * result + ((getReturnLogisticsCompany() == null) ? 0 : getReturnLogisticsCompany().hashCode()); + result = prime * result + ((getReturnLogisticsCode() == null) ? 0 : getReturnLogisticsCode().hashCode()); + result = prime * result + ((getReceiveTime() == null) ? 0 : getReceiveTime().hashCode()); + result = prime * result + ((getRemark() == null) ? 0 : getRemark().hashCode()); + result = prime * result + ((getContactperson() == null) ? 0 : getContactperson().hashCode()); + result = prime * result + ((getMobile() == null) ? 0 : getMobile().hashCode()); + result = prime * result + ((getAddress() == null) ? 0 : getAddress().hashCode()); + result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); + result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); + result = prime * result + ((getCreateBy() == null) ? 0 : getCreateBy().hashCode()); + result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); + result = prime * result + ((getUpdateBy() == null) ? 0 : getUpdateBy().hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append(" ["); + sb.append("Hash = ").append(hashCode()); + sb.append(", id=").append(id); + sb.append(", refundNum=").append(refundNum); + sb.append(", refundType=").append(refundType); + sb.append(", shopId=").append(shopId); + sb.append(", shopType=").append(shopType); + sb.append(", orderNum=").append(orderNum); + sb.append(", orderItemNum=").append(orderItemNum); + sb.append(", skuId=").append(skuId); + sb.append(", erpGoodsId=").append(erpGoodsId); + sb.append(", erpSkuId=").append(erpSkuId); + sb.append(", skuNum=").append(skuNum); + sb.append(", goodsName=").append(goodsName); + sb.append(", goodsSku=").append(goodsSku); + sb.append(", goodsImage=").append(goodsImage); + sb.append(", quantity=").append(quantity); + sb.append(", returnLogisticsCompany=").append(returnLogisticsCompany); + sb.append(", returnLogisticsCode=").append(returnLogisticsCode); + sb.append(", receiveTime=").append(receiveTime); + sb.append(", remark=").append(remark); + sb.append(", contactperson=").append(contactperson); + sb.append(", mobile=").append(mobile); + sb.append(", address=").append(address); + sb.append(", status=").append(status); + sb.append(", createTime=").append(createTime); + sb.append(", createBy=").append(createBy); + sb.append(", updateTime=").append(updateTime); + sb.append(", updateBy=").append(updateBy); + sb.append(", serialVersionUID=").append(serialVersionUID); + sb.append("]"); + return sb.toString(); + } +} \ No newline at end of file diff --git a/sys-api/src/main/java/com/qihang/sys/api/mapper/JdRefundMapper.java b/sys-api/src/main/java/com/qihang/sys/api/mapper/JdRefundMapper.java new file mode 100644 index 00000000..d66871b6 --- /dev/null +++ b/sys-api/src/main/java/com/qihang/sys/api/mapper/JdRefundMapper.java @@ -0,0 +1,18 @@ +package com.qihang.sys.api.mapper; + +import com.qihang.sys.api.domain.JdRefund; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author qilip +* @description 针对表【jd_refund】的数据库操作Mapper +* @createDate 2024-03-10 16:28:25 +* @Entity com.qihang.sys.api.domain.JdRefund +*/ +public interface JdRefundMapper extends BaseMapper { + +} + + + + diff --git a/sys-api/src/main/java/com/qihang/sys/api/mapper/ORefundMapper.java b/sys-api/src/main/java/com/qihang/sys/api/mapper/ORefundMapper.java new file mode 100644 index 00000000..e58d66cd --- /dev/null +++ b/sys-api/src/main/java/com/qihang/sys/api/mapper/ORefundMapper.java @@ -0,0 +1,18 @@ +package com.qihang.sys.api.mapper; + +import com.qihang.sys.api.domain.ORefund; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** +* @author qilip +* @description 针对表【o_refund(退换货表)】的数据库操作Mapper +* @createDate 2024-03-10 16:23:12 +* @Entity com.qihang.sys.api.domain.ORefund +*/ +public interface ORefundMapper extends BaseMapper { + +} + + + + diff --git a/sys-api/src/main/java/com/qihang/sys/api/mq/ApiMessageReceiver.java b/sys-api/src/main/java/com/qihang/sys/api/mq/ApiMessageReceiver.java index fd2fd9d7..9bcee2d4 100644 --- a/sys-api/src/main/java/com/qihang/sys/api/mq/ApiMessageReceiver.java +++ b/sys-api/src/main/java/com/qihang/sys/api/mq/ApiMessageReceiver.java @@ -8,6 +8,7 @@ import com.qihang.common.mq.MqType; import com.qihang.common.utils.SpringUtils; import com.qihang.sys.api.mapper.OOrderMapper; import com.qihang.sys.api.service.OOrderService; +import com.qihang.sys.api.service.ORefundService; import jakarta.annotation.Resource; import lombok.AllArgsConstructor; import org.slf4j.Logger; @@ -54,6 +55,10 @@ public class ApiMessageReceiver implements MessageListener { }else if(vo.getShopType().getIndex() == EnumShopType.TAO.getIndex()) { orderService.taoOrderMessage(vo.getKeyId()); } + }else if(vo.getMqType() == MqType.REFUND_MESSAGE){ + logger.info("退款消息"+messageContent); + ORefundService refundService = SpringUtils.getBean(ORefundService.class); + refundService.jdRefundMessage(vo.getKeyId()); } } } diff --git a/sys-api/src/main/java/com/qihang/sys/api/service/JdRefundService.java b/sys-api/src/main/java/com/qihang/sys/api/service/JdRefundService.java new file mode 100644 index 00000000..a5e81a5e --- /dev/null +++ b/sys-api/src/main/java/com/qihang/sys/api/service/JdRefundService.java @@ -0,0 +1,13 @@ +package com.qihang.sys.api.service; + +import com.qihang.sys.api.domain.JdRefund; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author qilip +* @description 针对表【jd_refund】的数据库操作Service +* @createDate 2024-03-10 16:28:25 +*/ +public interface JdRefundService extends IService { + +} diff --git a/sys-api/src/main/java/com/qihang/sys/api/service/ORefundService.java b/sys-api/src/main/java/com/qihang/sys/api/service/ORefundService.java new file mode 100644 index 00000000..1f8134d7 --- /dev/null +++ b/sys-api/src/main/java/com/qihang/sys/api/service/ORefundService.java @@ -0,0 +1,14 @@ +package com.qihang.sys.api.service; + +import com.qihang.common.common.ResultVo; +import com.qihang.sys.api.domain.ORefund; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author qilip +* @description 针对表【o_refund(退换货表)】的数据库操作Service +* @createDate 2024-03-10 16:23:12 +*/ +public interface ORefundService extends IService { + ResultVo jdRefundMessage(String refundId); +} diff --git a/sys-api/src/main/java/com/qihang/sys/api/service/impl/JdRefundServiceImpl.java b/sys-api/src/main/java/com/qihang/sys/api/service/impl/JdRefundServiceImpl.java new file mode 100644 index 00000000..7c457bf4 --- /dev/null +++ b/sys-api/src/main/java/com/qihang/sys/api/service/impl/JdRefundServiceImpl.java @@ -0,0 +1,22 @@ +package com.qihang.sys.api.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.qihang.sys.api.domain.JdRefund; +import com.qihang.sys.api.service.JdRefundService; +import com.qihang.sys.api.mapper.JdRefundMapper; +import org.springframework.stereotype.Service; + +/** +* @author qilip +* @description 针对表【jd_refund】的数据库操作Service实现 +* @createDate 2024-03-10 16:28:25 +*/ +@Service +public class JdRefundServiceImpl extends ServiceImpl + implements JdRefundService{ + +} + + + + diff --git a/sys-api/src/main/java/com/qihang/sys/api/service/impl/ORefundServiceImpl.java b/sys-api/src/main/java/com/qihang/sys/api/service/impl/ORefundServiceImpl.java new file mode 100644 index 00000000..70006b25 --- /dev/null +++ b/sys-api/src/main/java/com/qihang/sys/api/service/impl/ORefundServiceImpl.java @@ -0,0 +1,56 @@ +package com.qihang.sys.api.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.qihang.common.common.ResultVo; +import com.qihang.common.common.ResultVoEnum; +import com.qihang.sys.api.domain.JdRefund; +import com.qihang.sys.api.domain.ORefund; +import com.qihang.sys.api.mapper.JdRefundMapper; +import com.qihang.sys.api.service.ORefundService; +import com.qihang.sys.api.mapper.ORefundMapper; +import lombok.AllArgsConstructor; +import lombok.extern.java.Log; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** +* @author qilip +* @description 针对表【o_refund(退换货表)】的数据库操作Service实现 +* @createDate 2024-03-10 16:23:12 +*/ +@Log +@AllArgsConstructor +@Service +public class ORefundServiceImpl extends ServiceImpl + implements ORefundService{ + private final ORefundMapper mapper; + private final JdRefundMapper jdRefundMapper; + @Transactional + @Override + public ResultVo jdRefundMessage(String refundId) { + log.info("京东退款消息处理"+refundId); + // TODO:业务问题:一个订单退款单是否包含多个商品;一个京东订单是否包含多个ITEM + List jdRefunds = jdRefundMapper.selectList(new LambdaQueryWrapper().eq(JdRefund::getRefundId, refundId)); + if(jdRefunds == null || jdRefunds.size() == 0) { + // 没有找到订单信息 + return new ResultVo<>(ResultVoEnum.NotFound,"没有找到京东退款单:"+refundId); + } + JdRefund jdRefund = jdRefunds.get(0); + List oRefunds = mapper.selectList(new LambdaQueryWrapper().eq(ORefund::getRefundNum, jdRefund.getRefundId())); + if(oRefunds == null || oRefunds.isEmpty()) { + // 新增 + ORefund insert = new ORefund(); + + }else{ + // 修改 + } + return null; + } +} + + + + diff --git a/sys-api/src/main/resources/mapper/JdRefundMapper.xml b/sys-api/src/main/resources/mapper/JdRefundMapper.xml new file mode 100644 index 00000000..fd2dd1c3 --- /dev/null +++ b/sys-api/src/main/resources/mapper/JdRefundMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + id,shop_id,refund_id, + buyer_id,buyer_name,check_time, + apply_time,apply_refund_sum,status, + check_username,order_id + + diff --git a/sys-api/src/main/resources/mapper/ORefundMapper.xml b/sys-api/src/main/resources/mapper/ORefundMapper.xml new file mode 100644 index 00000000..6f13bd39 --- /dev/null +++ b/sys-api/src/main/resources/mapper/ORefundMapper.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id,refund_num,refund_type, + shop_id,shop_type,order_num, + order_item_num,sku_id,erp_goods_id, + erp_sku_id,sku_num,goods_name, + goods_sku,goods_image,quantity, + return_logistics_company,return_logistics_code,receive_time, + remark,contactPerson,mobile, + address,status,create_time, + create_by,update_time,update_by + +