From eb42849b3ec40cd00260415ecc90920bbb8f99f1 Mon Sep 17 00:00:00 2001 From: chenjiajun Date: Mon, 5 Jul 2021 09:30:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=94=AE=E5=90=8E=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + sql/yshop.pdman.json | 401 ++++- yshop-admin/pom.xml | 63 +- .../src/main/resources/config/application.yml | 7 +- .../modules/coupon/rest/CouponController.java | 18 + .../order/rest/StoreOrderController.java | 267 ++-- .../product/param/CollectDelFootParam.java | 20 + .../product/rest/StoreProductController.java | 25 +- .../sales/rest/StoreAfterSalesController.java | 178 +++ .../co/yixiang/gen/domain/vo/TableInfo.java | 2 + .../service/YxStoreCouponUserService.java | 75 +- .../impl/YxStoreCouponUserServiceImpl.java | 45 +- .../order/domain/YxStoreOrderCartInfo.java | 3 + .../order/service/YxStoreOrderService.java | 4 +- .../impl/YxStoreOrderCartInfoServiceImpl.java | 1 + .../service/impl/YxStoreOrderServiceImpl.java | 1302 ++++++++--------- .../YxStoreProductRelationService.java | 5 + .../YxStoreProductRelationServiceImpl.java | 5 + .../mapper/YxStoreProductRelationMapper.java | 2 +- .../modules/sales/domain/StoreAfterSales.java | 79 + .../sales/domain/StoreAfterSalesItem.java | 30 + .../sales/domain/StoreAfterSalesStatus.java | 35 + .../modules/sales/param/ProsuctParam.java | 16 + .../modules/sales/param/SalesCheckDto.java | 40 + .../sales/param/StoreAfterSalesParam.java | 48 + .../sales/param/YxStoreAfterSalesDto.java | 75 + .../param/YxStoreAfterSalesQueryCriteria.java | 41 + .../service/StoreAfterSalesItemService.java | 10 + .../sales/service/StoreAfterSalesService.java | 130 ++ .../service/StoreAfterSalesStatusService.java | 10 + .../impl/StoreAfterSalesItemServiceImpl.java | 19 + .../impl/StoreAfterSalesServiceImpl.java | 414 ++++++ .../StoreAfterSalesStatusServiceImpl.java | 19 + .../mapper/StoreAfterSalesItemMapper.java | 10 + .../service/mapper/StoreAfterSalesMapper.java | 10 + .../mapper/StoreAfterSalesStatusMapper.java | 10 + .../sales/service/vo/StoreAfterSalesVo.java | 122 ++ .../service/vo/YxStoreOrderCartInfoVo.java | 46 + .../sales/StoreAfterSalesController.java | 113 ++ .../modules/mp/service/WeixinPayService.java | 7 +- 40 files changed, 2859 insertions(+), 849 deletions(-) create mode 100644 yshop-app/src/main/java/co/yixiang/modules/product/param/CollectDelFootParam.java create mode 100644 yshop-app/src/main/java/co/yixiang/sales/rest/StoreAfterSalesController.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSales.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesItem.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesStatus.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/param/ProsuctParam.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/param/SalesCheckDto.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/param/StoreAfterSalesParam.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesDto.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesQueryCriteria.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesItemService.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesService.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesStatusService.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesItemServiceImpl.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesServiceImpl.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesStatusServiceImpl.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesItemMapper.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesMapper.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesStatusMapper.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/service/vo/StoreAfterSalesVo.java create mode 100644 yshop-mall/src/main/java/co/yixiang/modules/sales/service/vo/YxStoreOrderCartInfoVo.java create mode 100644 yshop-shop/src/main/java/co/yixiang/modules/sales/StoreAfterSalesController.java diff --git a/.gitignore b/.gitignore index 47674fd5..dc93fe14 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ target .idea/ *.log logs +*.DS_Store diff --git a/sql/yshop.pdman.json b/sql/yshop.pdman.json index 5da5ed4c..783d2b7a 100644 --- a/sql/yshop.pdman.json +++ b/sql/yshop.pdman.json @@ -5883,6 +5883,53 @@ "autoIncrement": false, "defaultValue": "" } + ], + "indexs": [], + "headers": [ + { + "fieldName": "chnname", + "relationNoShow": false + }, + { + "fieldName": "name", + "relationNoShow": false + }, + { + "fieldName": "type", + "relationNoShow": false + }, + { + "fieldName": "dataType", + "relationNoShow": true + }, + { + "fieldName": "remark", + "relationNoShow": true + }, + { + "fieldName": "pk", + "relationNoShow": false + }, + { + "fieldName": "notNull", + "relationNoShow": true + }, + { + "fieldName": "autoIncrement", + "relationNoShow": true + }, + { + "fieldName": "defaultValue", + "relationNoShow": true + }, + { + "fieldName": "relationNoShow", + "relationNoShow": true + }, + { + "fieldName": "uiHint", + "relationNoShow": true + } ] }, { @@ -6213,17 +6260,6 @@ "field": "id" } }, - { - "relation": "0,n:1", - "from": { - "entity": "yx_store_order_cart_info", - "field": "cart_id" - }, - "to": { - "entity": "yx_store_cart", - "field": "id" - } - }, { "relation": "0,n:1", "from": { @@ -11339,6 +11375,347 @@ "edges": [] }, "associations": [] + }, + { + "name": "after_sales", + "chnname": "售后", + "entities": [ + { + "title": "yx_store_after_sales", + "fields": [ + { + "name": "id", + "type": "BIGINT UNSIGNED_20", + "remark": "", + "chnname": "", + "pk": true, + "notNull": true, + "autoIncrement": true + }, + { + "name": "order_code", + "type": "BIGINT UNSIGNED_20", + "remark": "", + "chnname": "订单号" + }, + { + "name": "refund_amount", + "type": "Money", + "remark": "", + "chnname": "退款金额" + }, + { + "name": "service_type", + "type": "YesNo", + "remark": "", + "chnname": "服务类型0仅退款1退货退款" + }, + { + "name": "reasons", + "type": "MiddleString", + "remark": "", + "chnname": "申请原因" + }, + { + "name": "explain", + "type": "LongText", + "remark": "", + "chnname": "说明" + }, + { + "name": "explain_img", + "type": "LongText", + "remark": "", + "chnname": "说明图片->多个用逗号分割" + }, + { + "name": "delivery_sn", + "type": "DefaultString", + "remark": "", + "chnname": "物流单号" + }, + { + "name": "delivery_name", + "type": "DefaultString", + "remark": "", + "chnname": "物流名称" + }, + { + "name": "state", + "type": "DefaultString", + "remark": "", + "chnname": "状态" + }, + { + "name": "create_time", + "type": "DATETIME", + "chnname": "添加时间", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "is_del", + "type": "BIT_1", + "chnname": "逻辑删除", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + } + ], + "indexs": [], + "headers": [ + { + "fieldName": "chnname", + "relationNoShow": false + }, + { + "fieldName": "name", + "relationNoShow": false + }, + { + "fieldName": "type", + "relationNoShow": false + }, + { + "fieldName": "dataType", + "relationNoShow": true + }, + { + "fieldName": "remark", + "relationNoShow": true + }, + { + "fieldName": "pk", + "relationNoShow": false + }, + { + "fieldName": "notNull", + "relationNoShow": true + }, + { + "fieldName": "autoIncrement", + "relationNoShow": true + }, + { + "fieldName": "defaultValue", + "relationNoShow": true + }, + { + "fieldName": "relationNoShow", + "relationNoShow": true + }, + { + "fieldName": "uiHint", + "relationNoShow": true + } + ], + "chnname": "售后记录表" + }, + { + "title": "yx_store_after_sales_item", + "fields": [ + { + "name": "id", + "type": "BIGINT UNSIGNED_20", + "remark": "", + "chnname": "主键id", + "pk": true, + "notNull": true, + "autoIncrement": true + }, + { + "name": "store_after_sales_id", + "type": "BIGINT UNSIGNED_20", + "remark": "", + "chnname": "售后id" + }, + { + "name": "product_id", + "type": "BIGINT UNSIGNED_20", + "remark": "", + "chnname": "商品id" + }, + { + "name": "cart_info", + "type": "DefaultString", + "remark": "", + "chnname": "退货东西的详情信息" + }, + { + "name": "is_del", + "type": "BIT_1", + "chnname": "逻辑删除", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + } + ], + "indexs": [], + "headers": [ + { + "fieldName": "chnname", + "relationNoShow": false + }, + { + "fieldName": "name", + "relationNoShow": false + }, + { + "fieldName": "type", + "relationNoShow": false + }, + { + "fieldName": "dataType", + "relationNoShow": true + }, + { + "fieldName": "remark", + "relationNoShow": true + }, + { + "fieldName": "pk", + "relationNoShow": false + }, + { + "fieldName": "notNull", + "relationNoShow": true + }, + { + "fieldName": "autoIncrement", + "relationNoShow": true + }, + { + "fieldName": "defaultValue", + "relationNoShow": true + }, + { + "fieldName": "relationNoShow", + "relationNoShow": true + }, + { + "fieldName": "uiHint", + "relationNoShow": true + } + ], + "chnname": "售后子表" + }, + { + "title": "yx_store_after_sales_status", + "fields": [ + { + "name": "id", + "type": "BIGINT UNSIGNED_20", + "remark": "", + "chnname": "", + "pk": true, + "notNull": true, + "autoIncrement": true + }, + { + "name": "store_after_sales_id", + "type": "BIGINT UNSIGNED_20", + "chnname": "售后id", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "change_type", + "type": "DefaultString", + "chnname": "操作类型", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "change_message", + "type": "ShortString", + "chnname": "操作备注", + "remark": "", + "pk": false, + "notNull": false, + "autoIncrement": false, + "defaultValue": "" + }, + { + "name": "change_time", + "type": "DateTime", + "remark": "", + "chnname": "操作时间" + }, + { + "name": "operator", + "type": "DefaultString", + "remark": "", + "chnname": "操作人" + } + ], + "indexs": [], + "headers": [ + { + "fieldName": "chnname", + "relationNoShow": false + }, + { + "fieldName": "name", + "relationNoShow": false + }, + { + "fieldName": "type", + "relationNoShow": false + }, + { + "fieldName": "dataType", + "relationNoShow": true + }, + { + "fieldName": "remark", + "relationNoShow": true + }, + { + "fieldName": "pk", + "relationNoShow": false + }, + { + "fieldName": "notNull", + "relationNoShow": true + }, + { + "fieldName": "autoIncrement", + "relationNoShow": true + }, + { + "fieldName": "defaultValue", + "relationNoShow": true + }, + { + "fieldName": "relationNoShow", + "relationNoShow": true + }, + { + "fieldName": "uiHint", + "relationNoShow": true + } + ], + "chnname": "售后订单操作详情表" + } + ], + "graphCanvas": { + "nodes": [], + "edges": [] + }, + "associations": [] } ], "dataTypeDomains": { @@ -12324,4 +12701,4 @@ ], "wordTemplateConfig": "" } -} +} \ No newline at end of file diff --git a/yshop-admin/pom.xml b/yshop-admin/pom.xml index 25feb5dc..221cc10e 100644 --- a/yshop-admin/pom.xml +++ b/yshop-admin/pom.xml @@ -34,10 +34,10 @@ yshop-shop 3.2 - - org.springframework.boot - spring-boot-starter-websocket - + + org.springframework.boot + spring-boot-starter-websocket + @@ -46,28 +46,51 @@ jjwt 0.9.1 - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + org.quartz-scheduler quartz - + + + co.yixiang + yshop-weixin + 3.2 + + + org.springframework.boot + spring-boot-starter-security + + + + + org.springframework.security + spring-security-core + + + org.springframework.security + spring-security-web + + + org.springframework.security + spring-security-config + diff --git a/yshop-admin/src/main/resources/config/application.yml b/yshop-admin/src/main/resources/config/application.yml index c9422163..ca98f4d3 100644 --- a/yshop-admin/src/main/resources/config/application.yml +++ b/yshop-admin/src/main/resources/config/application.yml @@ -52,9 +52,10 @@ yshop: logging: level: - co.yixiang: ERROR - org.springframework.web: ERROR - me.chanjar.weixin: ERROR + co.yixiang: DEBUG + org.springframework.web: DEBUG + com.github.binarywang.demo.wx.mp: DEBUG + me.chanjar.weixin: DEBUG mybatis-plus: check-config-location: true diff --git a/yshop-app/src/main/java/co/yixiang/modules/coupon/rest/CouponController.java b/yshop-app/src/main/java/co/yixiang/modules/coupon/rest/CouponController.java index ee1bb48f..bc01332f 100644 --- a/yshop-app/src/main/java/co/yixiang/modules/coupon/rest/CouponController.java +++ b/yshop-app/src/main/java/co/yixiang/modules/coupon/rest/CouponController.java @@ -37,6 +37,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; +import java.util.Map; /** *

@@ -106,6 +107,23 @@ public class CouponController { return ApiResult.ok(list); } + /** + * 用户已领取优惠券pc + */ + @AppLog(value = "用户已领取优惠券pc", type = 1) + @AuthCheck + @GetMapping("/coupons/user/pc/{type}") + @ApiOperation(value = "用户已领取优惠券pc",notes = "用户已领取优惠券pc") + public ApiResult getUserPCList( + @RequestParam(value = "page", defaultValue = "1") int page, + @RequestParam(value = "limit", defaultValue = "10") int limit, @PathVariable(value = "type") Integer type){ + Long uid = LocalUser.getUser().getUid(); + Map map = storeCouponUserService.getUserPCCoupon(uid,page,limit,type); + Long total = (Long) map.get("total"); + Long totalPage = (Long) map.get("totalPage"); + return ApiResult.resultPage(total.intValue(), totalPage.intValue(), map.get("list")); + } + /** * 优惠券 订单获取 */ diff --git a/yshop-app/src/main/java/co/yixiang/modules/order/rest/StoreOrderController.java b/yshop-app/src/main/java/co/yixiang/modules/order/rest/StoreOrderController.java index b884364a..64128902 100644 --- a/yshop-app/src/main/java/co/yixiang/modules/order/rest/StoreOrderController.java +++ b/yshop-app/src/main/java/co/yixiang/modules/order/rest/StoreOrderController.java @@ -13,27 +13,21 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import co.yixiang.api.ApiResult; import co.yixiang.api.YshopException; -import co.yixiang.enums.*; -import co.yixiang.logging.aop.log.AppLog; import co.yixiang.common.aop.NoRepeatSubmit; import co.yixiang.common.bean.LocalUser; import co.yixiang.common.interceptor.AuthCheck; +import co.yixiang.enums.*; +import co.yixiang.logging.aop.log.AppLog; import co.yixiang.modules.mp.domain.YxWechatTemplate; +import co.yixiang.modules.mp.service.WeixinPayService; import co.yixiang.modules.mp.service.YxWechatTemplateService; import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.domain.YxStoreOrderCartInfo; import co.yixiang.modules.order.dto.OrderExtendDto; -import co.yixiang.modules.order.param.ComputeOrderParam; -import co.yixiang.modules.order.param.ConfirmOrderParam; -import co.yixiang.modules.order.param.DoOrderParam; -import co.yixiang.modules.order.param.ExpressParam; -import co.yixiang.modules.order.param.HandleOrderParam; -import co.yixiang.modules.order.param.OrderParam; -import co.yixiang.modules.order.param.OrderVerifyParam; -import co.yixiang.modules.order.param.PayParam; -import co.yixiang.modules.order.param.ProductOrderParam; -import co.yixiang.modules.order.param.ProductReplyParam; -import co.yixiang.modules.order.param.RefundParam; +import co.yixiang.modules.order.param.*; +import co.yixiang.modules.order.service.YxStoreOrderCartInfoService; import co.yixiang.modules.order.service.YxStoreOrderService; +import co.yixiang.modules.order.service.YxStoreOrderStatusService; import co.yixiang.modules.order.service.dto.YxStoreOrderDto; import co.yixiang.modules.order.vo.ComputeVo; import co.yixiang.modules.order.vo.ConfirmOrderVo; @@ -45,6 +39,7 @@ import co.yixiang.modules.user.domain.YxUser; import co.yixiang.tools.express.ExpressService; import co.yixiang.tools.express.config.ExpressAutoConfiguration; import co.yixiang.tools.express.dao.ExpressInfo; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.vdurmont.emoji.EmojiParser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -55,16 +50,14 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.math.BigDecimal; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -85,6 +78,10 @@ public class StoreOrderController { private final OrderSupplyService orderSupplyService; private final CreatShareProductService creatShareProductService; private final YxWechatTemplateService yxWechatTemplateService; + private final YxStoreOrderStatusService orderStatusService; + + private final YxStoreOrderCartInfoService storeOrderCartInfoService; + private final WeixinPayService weixinPayService; @Value("${file.path}") private String path; @@ -96,10 +93,10 @@ public class StoreOrderController { @AppLog(value = "订单确认", type = 1) @AuthCheck @PostMapping("/order/confirm") - @ApiOperation(value = "订单确认",notes = "订单确认") - public ApiResult confirm(@Validated @RequestBody ConfirmOrderParam param){ + @ApiOperation(value = "订单确认", notes = "订单确认") + public ApiResult confirm(@Validated @RequestBody ConfirmOrderParam param) { YxUser yxUser = LocalUser.getUser(); - return ApiResult.ok(storeOrderService.confirmOrder(yxUser,param.getCartId())); + return ApiResult.ok(storeOrderService.confirmOrder(yxUser, param.getCartId())); } @@ -111,25 +108,25 @@ public class StoreOrderController { @ApiImplicitParams({ @ApiImplicitParam(name = "key", value = "唯一的key", paramType = "query", dataType = "string") }) - @ApiOperation(value = "计算订单金额",notes = "计算订单金额") - public ApiResult> computedOrder(@Validated @RequestBody ComputeOrderParam param, - @PathVariable String key){ + @ApiOperation(value = "计算订单金额", notes = "计算订单金额") + public ApiResult> computedOrder(@Validated @RequestBody ComputeOrderParam param, + @PathVariable String key) { YxUser yxUser = LocalUser.getUser(); - Map map = orderSupplyService.check(yxUser.getUid(),key,param); - if(OrderLogEnum.EXTEND_ORDER.getValue().equals(map.get("status")) + Map map = orderSupplyService.check(yxUser.getUid(), key, param); + if (OrderLogEnum.EXTEND_ORDER.getValue().equals(map.get("status")) || OrderLogEnum.PINK_ORDER_FAIL_1.getValue().equals(map.get("status")) - || OrderLogEnum.PINK_ORDER_FAIL_2.getValue().equals(map.get("status")) ){ - return ApiResult.ok(map,map.get("msg").toString()); + || OrderLogEnum.PINK_ORDER_FAIL_2.getValue().equals(map.get("status"))) { + return ApiResult.ok(map, map.get("msg").toString()); } - ComputeVo computeVo = storeOrderService.computedOrder(yxUser,key, + ComputeVo computeVo = storeOrderService.computedOrder(yxUser, key, param.getCouponId(), param.getUseIntegral(), param.getShippingType(), param.getAddressId()); - map.put("result",computeVo); - map.put("status",OrderLogEnum.NONE_ORDER.getValue()); + map.put("result", computeVo); + map.put("status", OrderLogEnum.NONE_ORDER.getValue()); return ApiResult.ok(map); } @@ -140,24 +137,24 @@ public class StoreOrderController { @AuthCheck @NoRepeatSubmit @PostMapping("/order/create/{key}") - @ApiOperation(value = "订单创建",notes = "订单创建") - public ApiResult> create(@Valid @RequestBody OrderParam param, - @PathVariable String key){ + @ApiOperation(value = "订单创建", notes = "订单创建") + public ApiResult> create(@Valid @RequestBody OrderParam param, + @PathVariable String key) { YxUser yxUser = LocalUser.getUser(); ComputeOrderParam computeOrderParam = new ComputeOrderParam(); - BeanUtil.copyProperties(param,computeOrderParam); - Map map = orderSupplyService.check(yxUser.getUid(),key,computeOrderParam); - if(OrderLogEnum.EXTEND_ORDER.getValue().equals(map.get("status")) + BeanUtil.copyProperties(param, computeOrderParam); + Map map = orderSupplyService.check(yxUser.getUid(), key, computeOrderParam); + if (OrderLogEnum.EXTEND_ORDER.getValue().equals(map.get("status")) || OrderLogEnum.PINK_ORDER_FAIL_2.getValue().equals(map.get("status")) - || OrderLogEnum.PINK_ORDER_FAIL_1.getValue().equals(map.get("status")) ){ - return ApiResult.ok(map,map.get("msg").toString()); + || OrderLogEnum.PINK_ORDER_FAIL_1.getValue().equals(map.get("status"))) { + return ApiResult.ok(map, map.get("msg").toString()); } //创建订单 - YxStoreOrder order = storeOrderService.createOrder(yxUser,key,param); + YxStoreOrder order = storeOrderService.createOrder(yxUser, key, param); - if(ObjectUtil.isNull(order)) { + if (ObjectUtil.isNull(order)) { throw new YshopException("订单生成失败"); } @@ -166,9 +163,9 @@ public class StoreOrderController { OrderExtendDto orderDTO = new OrderExtendDto(); orderDTO.setKey(key); orderDTO.setOrderId(orderId); - map.put("status",OrderLogEnum.CREATE_ORDER_SUCCESS.getValue()); - map.put("result",orderDTO); - map.put("createTime",order.getCreateTime()); + map.put("status", OrderLogEnum.CREATE_ORDER_SUCCESS.getValue()); + map.put("result", orderDTO); + map.put("createTime", order.getCreateTime()); //开始处理支付 //处理金额为0的情况 @@ -180,28 +177,27 @@ public class StoreOrderController { orderSupplyService.goPay(map,orderId,yxUser.getUid(), param.getPayType(),param.getFrom(),orderDTO); - - return ApiResult.ok(map,map.get("payMsg").toString()); + return ApiResult.ok(map, map.get("payMsg").toString()); } /** - * 订单支付 + * 订单支付 */ @AppLog(value = "订单支付", type = 1) @AuthCheck @PostMapping("/order/pay") - @ApiOperation(value = "订单支付",notes = "订单支付") - public ApiResult> pay(@Valid @RequestBody PayParam param){ - Map map = new LinkedHashMap<>(); + @ApiOperation(value = "订单支付", notes = "订单支付") + public ApiResult> pay(@Valid @RequestBody PayParam param) { + Map map = new LinkedHashMap<>(); Long uid = LocalUser.getUser().getUid(); YxStoreOrderQueryVo storeOrder = storeOrderService - .getOrderInfo(param.getUni(),uid); - if(ObjectUtil.isNull(storeOrder)) { + .getOrderInfo(param.getUni(), uid); + if (ObjectUtil.isNull(storeOrder)) { throw new YshopException("订单不存在"); } - if(OrderInfoEnum.REFUND_STATUS_1.getValue().equals(storeOrder.getPaid())) { + if (OrderInfoEnum.REFUND_STATUS_1.getValue().equals(storeOrder.getPaid())) { throw new YshopException("该订单已支付"); } @@ -209,22 +205,22 @@ public class StoreOrderController { OrderExtendDto orderDTO = new OrderExtendDto(); orderDTO.setOrderId(orderId); - map.put("status","SUCCESS"); - map.put("result",orderDTO); + map.put("status", "SUCCESS"); + map.put("result", orderDTO); - if(storeOrder.getPayPrice().compareTo(BigDecimal.ZERO) <= 0&&!param.getPaytype().equals(PayTypeEnum.INTEGRAL.getValue())){ - storeOrderService.yuePay(orderId,uid); - return ApiResult.ok(map,"支付成功"); + if (storeOrder.getPayPrice().compareTo(BigDecimal.ZERO) <= 0 && !param.getPaytype().equals(PayTypeEnum.INTEGRAL.getValue())) { + storeOrderService.yuePay(orderId, uid); + return ApiResult.ok(map, "支付成功"); } //处理是否已经修改过订单价格,如果修改用新的单号去拉起支付 - if(StrUtil.isNotBlank(storeOrder.getExtendOrderId())) { + if (StrUtil.isNotBlank(storeOrder.getExtendOrderId())) { orderId = storeOrder.getExtendOrderId(); } - orderSupplyService.goPay(map,orderId,uid, param.getPaytype(),param.getFrom(),orderDTO); + orderSupplyService.goPay(map, orderId, uid, param.getPaytype(), param.getFrom(), orderDTO); return ApiResult.ok(map); } @@ -241,15 +237,15 @@ public class StoreOrderController { @ApiImplicitParam(name = "page", value = "页码,默认为1", paramType = "query", dataType = "int"), @ApiImplicitParam(name = "limit", value = "页大小,默认为10", paramType = "query", dataType = "int") }) - @ApiOperation(value = "订单列表",notes = "订单列表") - public ApiResult orderList(@RequestParam(value = "type",defaultValue = "0") int type, - @RequestParam(value = "page",defaultValue = "1") int page, - @RequestParam(value = "limit",defaultValue = "10") int limit){ + @ApiOperation(value = "订单列表", notes = "订单列表") + public ApiResult orderList(@RequestParam(value = "type", defaultValue = "0") int type, + @RequestParam(value = "page", defaultValue = "1") int page, + @RequestParam(value = "limit", defaultValue = "10") int limit) { Long uid = LocalUser.getUser().getUid(); Map map = storeOrderService.orderList(uid, type, page, limit); - Long total = (Long)map.get("total"); - Long totalPage = (Long)map.get("totalPage"); - return ApiResult.resultPage(total.intValue(),totalPage.intValue(),map.get("list")); + Long total = (Long) map.get("total"); + Long totalPage = (Long) map.get("totalPage"); + return ApiResult.resultPage(total.intValue(), totalPage.intValue(), map.get("list")); } @@ -262,34 +258,32 @@ public class StoreOrderController { @ApiImplicitParams({ @ApiImplicitParam(name = "key", value = "唯一的key", paramType = "query", dataType = "string") }) - @ApiOperation(value = "订单详情",notes = "订单详情") - public ApiResult detail(@PathVariable String key){ + @ApiOperation(value = "订单详情", notes = "订单详情") + public ApiResult detail(@PathVariable String key) { Long uid = LocalUser.getUser().getUid(); - if(StrUtil.isEmpty(key)) { + if (StrUtil.isEmpty(key)) { throw new YshopException("参数错误"); } - YxStoreOrderQueryVo storeOrder = storeOrderService.getOrderInfo(key,uid); - if(ObjectUtil.isNull(storeOrder)){ + YxStoreOrderQueryVo storeOrder = storeOrderService.getOrderInfo(key, uid); + if (ObjectUtil.isNull(storeOrder)) { throw new YshopException("订单不存在"); } - storeOrder = creatShareProductService.handleQrcode(storeOrder,path); + storeOrder = creatShareProductService.handleQrcode(storeOrder, path); return ApiResult.ok(storeOrderService.handleOrder(storeOrder)); } - - /** * 订单收货 */ @AppLog(value = "订单收货", type = 1) @AuthCheck @PostMapping("/order/take") - @ApiOperation(value = "订单收货",notes = "订单收货") - public ApiResult orderTake(@Validated @RequestBody DoOrderParam param){ + @ApiOperation(value = "订单收货", notes = "订单收货") + public ApiResult orderTake(@Validated @RequestBody DoOrderParam param) { Long uid = LocalUser.getUser().getUid(); - storeOrderService.takeOrder(param.getUni(),uid); + storeOrderService.takeOrder(param.getUni(), uid); return ApiResult.ok(); } @@ -297,8 +291,8 @@ public class StoreOrderController { * 订单产品信息 */ @PostMapping("/order/product") - @ApiOperation(value = "订单产品信息",notes = "订单产品信息") - public ApiResult product(@Validated @RequestBody ProductOrderParam param){ + @ApiOperation(value = "订单产品信息", notes = "订单产品信息") + public ApiResult product(@Validated @RequestBody ProductOrderParam param) { return ApiResult.ok(orderSupplyService.getProductOrder(param.getUnique())); } @@ -309,12 +303,49 @@ public class StoreOrderController { @AuthCheck @NoRepeatSubmit @PostMapping("/order/comment") - @ApiOperation(value = "订单评价",notes = "订单评价") - public ApiResult comment(@Valid @RequestBody ProductReplyParam param){ + @ApiOperation(value = "订单评价", notes = "订单评价") + public ApiResult comment(@Valid @RequestBody ProductReplyParam param) { YxUser user = LocalUser.getUser(); - storeOrderService.orderComment(user,param.getUnique(), + YxStoreOrderCartInfo orderCartInfo = storeOrderCartInfoService + .getOne(Wrappers.lambdaQuery() + .eq(YxStoreOrderCartInfo::getUnique,param.getUnique())); + storeOrderService.orderComment(orderCartInfo, user, param.getUnique(), param.getComment(), - param.getPics(),param.getProductScore(),param.getServiceScore()); + param.getPics(), param.getProductScore(), param.getServiceScore()); + + //增加状态 + orderStatusService.create(orderCartInfo.getOid(), + OrderLogEnum.EVAL_ORDER.getValue(), + OrderLogEnum.EVAL_ORDER.getDesc()); + return ApiResult.ok(); + } + + /** + * 订单评价 + */ + @AppLog(value = "订单评价", type = 1) + @AuthCheck + @NoRepeatSubmit + @PostMapping("/order/comments") + @ApiOperation(value = "订单评价", notes = "订单评价") + public ApiResult comments(@Valid @RequestBody List param) { + YxUser user = LocalUser.getUser(); + if (param.size() > 0) { + YxStoreOrderCartInfo orderCartInfo = storeOrderCartInfoService + .getOne(Wrappers.lambdaQuery() + .eq(YxStoreOrderCartInfo::getUnique,param.get(0).getUnique())); + + for (ProductReplyParam productReplyParam : param) { + storeOrderService.orderComment(orderCartInfo , user, productReplyParam.getUnique(), + productReplyParam.getComment(), + productReplyParam.getPics(), productReplyParam.getProductScore(), productReplyParam.getServiceScore()); + } + + //增加状态 + orderStatusService.create(orderCartInfo.getOid(), + OrderLogEnum.EVAL_ORDER.getValue(), + OrderLogEnum.EVAL_ORDER.getDesc()); + } return ApiResult.ok(); } @@ -325,10 +356,10 @@ public class StoreOrderController { @AppLog(value = "订单删除", type = 1) @AuthCheck @PostMapping("/order/del") - @ApiOperation(value = "订单删除",notes = "订单删除") - public ApiResult orderDel(@Validated @RequestBody DoOrderParam param){ + @ApiOperation(value = "订单删除", notes = "订单删除") + public ApiResult orderDel(@Validated @RequestBody DoOrderParam param) { Long uid = LocalUser.getUser().getUid(); - storeOrderService.removeOrder(param.getUni(),uid); + storeOrderService.removeOrder(param.getUni(), uid); return ApiResult.ok(); } @@ -336,8 +367,8 @@ public class StoreOrderController { * 订单退款理由 */ @GetMapping("/order/refund/reason") - @ApiOperation(value = "订单退款理由",notes = "订单退款理由") - public ApiResult refundReason(){ + @ApiOperation(value = "订单退款理由", notes = "订单退款理由") + public ApiResult refundReason() { ArrayList list = new ArrayList<>(); list.add("收货地址填错了"); list.add("与描述不符"); @@ -356,13 +387,13 @@ public class StoreOrderController { @NoRepeatSubmit @AuthCheck @PostMapping("/order/refund/verify") - @ApiOperation(value = "订单退款审核",notes = "订单退款审核") - public ApiResult refundVerify(@RequestBody RefundParam param){ + @ApiOperation(value = "订单退款审核", notes = "订单退款审核") + public ApiResult refundVerify(@RequestBody RefundParam param) { Long uid = LocalUser.getUser().getUid(); storeOrderService.orderApplyRefund(param.getRefundReasonWapExplain(), param.getRefundReasonWapImg(), EmojiParser.removeAllEmojis(param.getText()), - param.getUni(),uid); + param.getUni(), uid); return ApiResult.ok(); } @@ -373,10 +404,22 @@ public class StoreOrderController { @NoRepeatSubmit @AuthCheck @PostMapping("/order/cancel") - @ApiOperation(value = "订单取消",notes = "订单取消") - public ApiResult cancelOrder(@Validated @RequestBody HandleOrderParam param){ + @ApiOperation(value = "订单取消", notes = "订单取消") + public ApiResult cancelOrder(@Validated @RequestBody HandleOrderParam param) { Long uid = LocalUser.getUser().getUid(); - storeOrderService.cancelOrder(param.getId(),uid); + YxStoreOrderQueryVo orderInfo = storeOrderService.getOrderInfo(param.getId(), uid); + if (ObjectUtil.isNull(orderInfo)) { + throw new YshopException("订单不存在"); + } + if (orderInfo.getStatus() != 0) { + throw new YshopException("订单不能取消"); + } + if (orderInfo.getPaid() == 1) { + BigDecimal bigDecimal = new BigDecimal("100"); + int payPrice = bigDecimal.multiply(orderInfo.getPayPrice()).intValue(); + weixinPayService.refundOrder(param.getId(),payPrice); + } + storeOrderService.cancelOrder(param.getId(), uid); return ApiResult.ok(); } @@ -386,8 +429,8 @@ public class StoreOrderController { */ @AuthCheck @PostMapping("/order/express") - @ApiOperation(value = "获取物流信息",notes = "获取物流信息") - public ApiResult express( @RequestBody ExpressParam expressInfoDo){ + @ApiOperation(value = "获取物流信息", notes = "获取物流信息") + public ApiResult express(@RequestBody ExpressParam expressInfoDo) { //顺丰轨迹查询处理 String lastFourNumber = ""; @@ -395,15 +438,15 @@ public class StoreOrderController { YxStoreOrderDto yxStoreOrderDto; yxStoreOrderDto = storeOrderService.getOrderDetail(Long.valueOf(expressInfoDo.getOrderCode())); lastFourNumber = yxStoreOrderDto.getUserPhone(); - if (lastFourNumber.length()==11) { - lastFourNumber = StrUtil.sub(lastFourNumber,lastFourNumber.length(),-4); + if (lastFourNumber.length() == 11) { + lastFourNumber = StrUtil.sub(lastFourNumber, lastFourNumber.length(), -4); } } ExpressService expressService = ExpressAutoConfiguration.expressService(); ExpressInfo expressInfo = expressService.getExpressInfo(expressInfoDo.getOrderCode(), - expressInfoDo.getShipperCode(), expressInfoDo.getLogisticCode(),lastFourNumber); - if(!expressInfo.isSuccess()) { + expressInfoDo.getShipperCode(), expressInfoDo.getLogisticCode(), lastFourNumber); + if (!expressInfo.isSuccess()) { throw new YshopException(expressInfo.getReason()); } return ApiResult.ok(expressInfo); @@ -416,12 +459,12 @@ public class StoreOrderController { @NoRepeatSubmit @AuthCheck @PostMapping("/order/order_verific") - @ApiOperation(value = "订单核销",notes = "订单核销") - public ApiResult orderVerify( @RequestBody OrderVerifyParam param){ + @ApiOperation(value = "订单核销", notes = "订单核销") + public ApiResult orderVerify(@RequestBody OrderVerifyParam param) { Long uid = LocalUser.getUser().getUid(); YxStoreOrderQueryVo orderQueryVo = storeOrderService.verifyOrder(param.getVerifyCode(), - param.getIsConfirm(),uid); - if(orderQueryVo != null) { + param.getIsConfirm(), uid); + if (orderQueryVo != null) { return ApiResult.ok(orderQueryVo); } @@ -429,16 +472,14 @@ public class StoreOrderController { } - - @AuthCheck @GetMapping("/order/getSubscribeTemplate") - @ApiOperation(value = "获取订阅消息模板ID",notes = "获取订阅消息模板ID") - public ApiResult> getSubscribeTemplate(){ + @ApiOperation(value = "获取订阅消息模板ID", notes = "获取订阅消息模板ID") + public ApiResult> getSubscribeTemplate() { List yxWechatTemplate = yxWechatTemplateService.lambdaQuery() - .eq(YxWechatTemplate::getType,"subscribe") + .eq(YxWechatTemplate::getType, "subscribe") .eq(YxWechatTemplate::getStatus, ShopCommonEnum.IS_STATUS_1.getValue()).list(); - List temId = yxWechatTemplate.stream().map(tem-> tem.getTempid()).collect(Collectors.toList()); + List temId = yxWechatTemplate.stream().map(tem -> tem.getTempid()).collect(Collectors.toList()); return ApiResult.ok(temId); } diff --git a/yshop-app/src/main/java/co/yixiang/modules/product/param/CollectDelFootParam.java b/yshop-app/src/main/java/co/yixiang/modules/product/param/CollectDelFootParam.java new file mode 100644 index 00000000..f24fdff7 --- /dev/null +++ b/yshop-app/src/main/java/co/yixiang/modules/product/param/CollectDelFootParam.java @@ -0,0 +1,20 @@ +package co.yixiang.modules.product.param; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * @author : gzlv 2021/6/26 19:17 + */ +@Getter +@Setter +@ApiModel("查询参数对象") +public class CollectDelFootParam { + + private List ids; +} diff --git a/yshop-app/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java b/yshop-app/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java index 611818df..bd94830e 100644 --- a/yshop-app/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java +++ b/yshop-app/src/main/java/co/yixiang/modules/product/rest/StoreProductController.java @@ -9,6 +9,7 @@ package co.yixiang.modules.product.rest; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; @@ -26,6 +27,7 @@ import co.yixiang.enums.AppFromEnum; import co.yixiang.enums.ProductEnum; import co.yixiang.enums.ShopCommonEnum; import co.yixiang.modules.product.domain.YxStoreProduct; +import co.yixiang.modules.product.param.CollectDelFootParam; import co.yixiang.modules.product.param.YxStoreProductQueryParam; import co.yixiang.modules.product.param.YxStoreProductRelationQueryParam; import co.yixiang.modules.product.service.YxStoreProductRelationService; @@ -49,12 +51,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.awt.FontFormatException; import java.io.File; @@ -263,6 +260,22 @@ public class StoreProductController { return ApiResult.ok(); } + /** + * 取消收藏/足跡 + */ + @AppLog(value = "删除足跡", type = 1) + @NoRepeatSubmit + @AuthCheck + @DeleteMapping("/collect/delFoot") + @ApiOperation(value = "删除足跡",notes = "删除足跡") + public ApiResult collectDelFoot(@Validated @RequestBody CollectDelFootParam param){ + if (CollectionUtil.isEmpty(param.getIds())){ + throw new YshopException("参数非法"); + } + productRelationService.collectDelFoot(param.getIds()); + return ApiResult.ok(); + } + /** * 获取产品评论 */ diff --git a/yshop-app/src/main/java/co/yixiang/sales/rest/StoreAfterSalesController.java b/yshop-app/src/main/java/co/yixiang/sales/rest/StoreAfterSalesController.java new file mode 100644 index 00000000..f16e8848 --- /dev/null +++ b/yshop-app/src/main/java/co/yixiang/sales/rest/StoreAfterSalesController.java @@ -0,0 +1,178 @@ +package co.yixiang.sales.rest; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import co.yixiang.api.ApiResult; +import co.yixiang.api.YshopException; +import co.yixiang.common.bean.LocalUser; +import co.yixiang.common.interceptor.AuthCheck; +import co.yixiang.logging.aop.log.AppLog; +import co.yixiang.modules.order.domain.YxExpress; +import co.yixiang.modules.order.service.YxExpressService; +import co.yixiang.modules.order.service.dto.YxExpressQueryCriteria; +import co.yixiang.modules.sales.param.StoreAfterSalesParam; +import co.yixiang.modules.sales.service.StoreAfterSalesItemService; +import co.yixiang.modules.sales.service.StoreAfterSalesService; +import co.yixiang.modules.sales.service.StoreAfterSalesStatusService; +import co.yixiang.modules.sales.service.vo.StoreAfterSalesVo; +import co.yixiang.modules.sales.service.vo.YxStoreOrderCartInfoVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * @author : gzlv 2021/6/27 16:00 + */ +@Slf4j +@RestController +@RequiredArgsConstructor(onConstructor = @__(@Autowired)) +@Api(value = "售后记录", tags = "用户:售后记录") +public class StoreAfterSalesController { + + @Autowired + private StoreAfterSalesService storeAfterSalesService; + @Autowired + private StoreAfterSalesItemService storeAfterSalesItemService; + @Autowired + private StoreAfterSalesStatusService storeAfterSalesStatusService; + @Autowired + private YxExpressService yxExpressService; + + @AuthCheck + @PostMapping("/applyForAfterSales") + @ApiOperation(value = "申请售后", notes = "申请售后") + public ApiResult applyForAfterSales(@RequestBody StoreAfterSalesParam storeAfterSalesParam) { + storeAfterSalesService.applyForAfterSales(LocalUser.getUser().getUid(), LocalUser.getUser().getNickname(), storeAfterSalesParam); + return ApiResult.ok(); + } + + @AuthCheck + @GetMapping("/applyForAfterSales/{key}") + @ApiOperation(value = "查询订单详情", notes = "查询订单详情") + public ApiResult> checkOrderDetails(@PathVariable String key) { + return ApiResult.ok(storeAfterSalesService.checkOrderDetails(key)); + } + + @AppLog(value = "查看售后列表", type = 1) + @AuthCheck + @GetMapping("/storeAfterSales/list") + @ApiOperation(value = "售后列表", notes = "售后列表") + public ApiResult salesList(@RequestParam(value = "type", defaultValue = "0") int type, + @RequestParam(value = "page", defaultValue = "1") int page, + @RequestParam(value = "limit", defaultValue = "10") int limit) { + Map map = storeAfterSalesService.salesList(LocalUser.getUser().getUid(), type, + page, null, limit); + Long total = (Long) map.get("total"); + Long totalPage = (Long) map.get("totalPage"); + return ApiResult.resultPage(total.intValue(), totalPage.intValue(), map.get("list")); + } + + @AppLog(value = "查看售後详情", type = 1) + @AuthCheck + @GetMapping("/store/detail/{key}/{id}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "key", value = "唯一的key", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "订单详情", notes = "订单详情") + public ApiResult detail(@PathVariable String key, @PathVariable Long id) { + Long uid = LocalUser.getUser().getUid(); + if (StrUtil.isEmpty(key)) { + throw new YshopException("参数错误"); + } + List storeInfo = storeAfterSalesService.getStoreInfo(key, id, uid); + if (storeInfo.size() < 1) { + throw new YshopException("售后订单不存在"); + } + storeAfterSalesService.handleSales(storeInfo.get(0)); + return ApiResult.ok(storeInfo.get(0)); + } + + @AppLog(value = "通过订单号搜索", type = 1) + @AuthCheck + @GetMapping("/store/detail/{key}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "key", value = "唯一的key", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "订单详情", notes = "订单详情") + public ApiResult> detail(@PathVariable String key) { + Long uid = LocalUser.getUser().getUid(); + if (StrUtil.isEmpty(key)) { + throw new YshopException("参数错误"); + } + List storeInfo = storeAfterSalesService.getStoreInfo(key, null, uid); + for (StoreAfterSalesVo storeAfterSalesVo : storeInfo) { + storeAfterSalesService.handleSales(storeAfterSalesVo); + } + if (ObjectUtil.isNull(storeInfo)) { + throw new YshopException("售后订单不存在"); + } + return ApiResult.ok(storeInfo); + } + + @AppLog(value = "撤销申请", type = 1) + @AuthCheck + @GetMapping("/revoke/{key}/{id}") + @ApiImplicitParams({ + @ApiImplicitParam(name = "key", value = "订单号", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "撤销申请", notes = "撤销申请") + public ApiResult revoke(@PathVariable String key, @PathVariable Long id) { + Long uid = LocalUser.getUser().getUid(); + if (StrUtil.isEmpty(key)) { + throw new YshopException("参数错误"); + } + Boolean revoke = storeAfterSalesService.revoke(key, id, uid); + return ApiResult.ok(revoke); + } + + @ApiOperation(value = "查询快递") + @GetMapping(value = "/yxExpress") + public ApiResult> getYxExpresss(YxExpressQueryCriteria criteria) { + return ApiResult.ok(yxExpressService.queryAll(criteria)); + } + + @AppLog(value = "添加物流信息", type = 1) + @AuthCheck + @PostMapping("/addLogisticsInformation") + @ApiImplicitParams({ + @ApiImplicitParam(name = "code", value = "快递公司编码", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "name", value = "快递公司名称", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "postalCode", value = "快递编号", paramType = "query", dataType = "string"), + @ApiImplicitParam(name = "orderCode", value = "订单编号", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "添加物流信息", notes = "添加物流信息") + public ApiResult addLogisticsInformation(@RequestParam String code, @RequestParam String name, @RequestParam String postalCode, @RequestParam String orderCode) { + Long uid = LocalUser.getUser().getUid(); + if (StrUtil.isEmpty(code) || StrUtil.isEmpty(name) || StrUtil.isEmpty(postalCode)) { + throw new YshopException("参数错误"); + } + Boolean revoke = storeAfterSalesService.addLogisticsInformation(code, name, postalCode, orderCode); + return ApiResult.ok(revoke); + } + + @AppLog(value = "删除售后订单", type = 1) + @AuthCheck + @DeleteMapping("/deleteAfterSalesOrder") + @ApiImplicitParams({ + @ApiImplicitParam(name = "orderCode", value = "订单编码", paramType = "query", dataType = "string") + }) + @ApiOperation(value = "删除售后订单", notes = "删除售后订单") + public ApiResult deleteAfterSalesOrder(@RequestParam String orderCode, @RequestParam Long id) { + Long uid = LocalUser.getUser().getUid(); + if (StrUtil.isEmpty(orderCode) || ObjectUtil.isEmpty(id)) { + throw new YshopException("参数错误"); + } + Boolean revoke = storeAfterSalesService.deleteAfterSalesOrder(orderCode, id); + return ApiResult.ok(revoke); + } + + +} diff --git a/yshop-generator/src/main/java/co/yixiang/gen/domain/vo/TableInfo.java b/yshop-generator/src/main/java/co/yixiang/gen/domain/vo/TableInfo.java index 6303f620..c1aa5ade 100644 --- a/yshop-generator/src/main/java/co/yixiang/gen/domain/vo/TableInfo.java +++ b/yshop-generator/src/main/java/co/yixiang/gen/domain/vo/TableInfo.java @@ -5,6 +5,7 @@ */ package co.yixiang.gen.domain.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -23,6 +24,7 @@ public class TableInfo { private Object tableName; /** 创建日期 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") private Object createTime; /** 数据库引擎 */ diff --git a/yshop-mall/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponUserService.java b/yshop-mall/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponUserService.java index 3c05680a..0214ccb3 100644 --- a/yshop-mall/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponUserService.java +++ b/yshop-mall/src/main/java/co/yixiang/modules/activity/service/YxStoreCouponUserService.java @@ -22,13 +22,14 @@ import java.util.List; import java.util.Map; /** -* @author hupeng -* @date 2020-05-13 -*/ -public interface YxStoreCouponUserService extends BaseService{ + * @author hupeng + * @date 2020-05-13 + */ +public interface YxStoreCouponUserService extends BaseService { /** * 获取当前用户优惠券数量 + * * @param uid uid * @return int */ @@ -38,33 +39,36 @@ public interface YxStoreCouponUserService extends BaseService beUsableCouponList(Long uid,String cartIds); + List beUsableCouponList(Long uid, String cartIds); /** * 获取下单时候满足的优惠券 - * @param uid uid - * @param price 总价格 + * + * @param uid uid + * @param price 总价格 * @param productIds list * @return list */ List getUsableCouponList(Long uid, double price, List productIds); - /** * 获取用户优惠券 + * * @param uid uid * @return list */ @@ -72,31 +76,46 @@ public interface YxStoreCouponUserService extends BaseService - */ - Map queryAll(YxStoreCouponUserQueryCriteria criteria, Pageable pageable); + void addUserCoupon(Long uid, Integer cid); /** - * 查询所有数据不分页 - * @param criteria 条件参数 - * @return List - */ + * 查询数据分页 + * + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreCouponUserQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * + * @param criteria 条件参数 + * @return List + */ List queryAll(YxStoreCouponUserQueryCriteria criteria); /** - * 导出数据 - * @param all 待导出的数据 - * @param response / - * @throws IOException / - */ + * 导出数据 + * + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ void download(List all, HttpServletResponse response) throws IOException; + + /** + * pc端查询优惠券 + * + * @param uid 用户id + * @param page 当前页码 + * @param limit 一页多少 + * @param type + * @return / + */ + Map getUserPCCoupon(Long uid, int page, int limit, Integer type); } diff --git a/yshop-mall/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponUserServiceImpl.java b/yshop-mall/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponUserServiceImpl.java index a39ac4a3..701aa6c0 100644 --- a/yshop-mall/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponUserServiceImpl.java +++ b/yshop-mall/src/main/java/co/yixiang/modules/activity/service/impl/YxStoreCouponUserServiceImpl.java @@ -33,6 +33,7 @@ import co.yixiang.modules.user.service.YxUserService; import co.yixiang.utils.FileUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; @@ -43,13 +44,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; @@ -319,4 +314,40 @@ public class YxStoreCouponUserServiceImpl extends BaseServiceImpl getUserPCCoupon(Long uid, int page, int limit, Integer type) { + Page yxStoreCouponUserPage = new Page<>(page, limit); + yxStoreCouponUserMapper.selectPage(yxStoreCouponUserPage,Wrappers.lambdaQuery() + .eq(YxStoreCouponUser::getUid,uid).eq(YxStoreCouponUser::getStatus,type)); + + List storeCouponUserQueryVoList = new ArrayList<>(); + long nowTime = System.currentTimeMillis(); + for (YxStoreCouponUser couponUser : yxStoreCouponUserPage.getRecords()) { + YxStoreCouponUserQueryVo queryVo = generator.convert(couponUser,YxStoreCouponUserQueryVo.class); + if(couponUser.getIsFail() == 1){ + queryVo.set_type(CouponEnum.USE_0.getValue()); + queryVo.set_msg("已失效"); + }else if (couponUser.getStatus() == 1){ + queryVo.set_type(CouponEnum.USE_0.getValue()); + queryVo.set_msg("已使用"); + }else if (couponUser.getStatus() == 2){ + queryVo.set_type(CouponEnum.USE_0.getValue()); + queryVo.set_msg("已过期"); + }else if(couponUser.getCreateTime().getTime() > nowTime || couponUser.getEndTime().getTime() < nowTime){ + queryVo.set_type(CouponEnum.USE_0.getValue()); + queryVo.set_msg("已过期"); + }else{ + queryVo.set_type(CouponEnum.USE_1.getValue()); + queryVo.set_msg("可使用"); + } + + storeCouponUserQueryVoList.add(queryVo); + } + Map map = new HashMap<>(); + map.put("list",storeCouponUserQueryVoList); + map.put("total",yxStoreCouponUserPage.getTotal()); + map.put("totalPage",yxStoreCouponUserPage.getPages()); + return map; + } } diff --git a/yshop-mall/src/main/java/co/yixiang/modules/order/domain/YxStoreOrderCartInfo.java b/yshop-mall/src/main/java/co/yixiang/modules/order/domain/YxStoreOrderCartInfo.java index 6c319292..468209ed 100644 --- a/yshop-mall/src/main/java/co/yixiang/modules/order/domain/YxStoreOrderCartInfo.java +++ b/yshop-mall/src/main/java/co/yixiang/modules/order/domain/YxStoreOrderCartInfo.java @@ -47,6 +47,9 @@ public class YxStoreOrderCartInfo implements Serializable { @TableField(value = "`unique`") private String unique; + /** 是否能售后0不能1能 */ + private Integer isAfterSales; + public void copy(YxStoreOrderCartInfo source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/yshop-mall/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java b/yshop-mall/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java index 84119278..08b1ef15 100644 --- a/yshop-mall/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java +++ b/yshop-mall/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java @@ -10,6 +10,7 @@ package co.yixiang.modules.order.service; import co.yixiang.common.service.BaseService; import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.domain.YxStoreOrderCartInfo; import co.yixiang.modules.order.param.OrderParam; import co.yixiang.modules.order.service.dto.OrderCountDto; import co.yixiang.modules.order.service.dto.OrderTimeDataDto; @@ -38,6 +39,7 @@ public interface YxStoreOrderService extends BaseService{ /** * 订单评价 + * @param orderCartInfo * @param user user * @param unique 订单orderCart唯一值 * @param comment 评论内容 @@ -45,7 +47,7 @@ public interface YxStoreOrderService extends BaseService{ * @param productScore 评分 * @param serviceScore 评分 */ - void orderComment(YxUser user, String unique, String comment, String pics, String productScore, + void orderComment(YxStoreOrderCartInfo orderCartInfo, YxUser user, String unique, String comment, String pics, String productScore, String serviceScore); /** diff --git a/yshop-mall/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderCartInfoServiceImpl.java b/yshop-mall/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderCartInfoServiceImpl.java index 265acaab..cbb584be 100644 --- a/yshop-mall/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderCartInfoServiceImpl.java +++ b/yshop-mall/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderCartInfoServiceImpl.java @@ -68,6 +68,7 @@ public class YxStoreOrderCartInfoServiceImpl extends BaseServiceImpl cartGroup = yxStoreCartService.getUserProductCartList(uid, - cartIds,ShopConstants.YSHOP_ONE_NUM); - if(ObjectUtil.isNotEmpty(cartGroup.get("invalid"))){ + cartIds, ShopConstants.YSHOP_ONE_NUM); + if (ObjectUtil.isNotEmpty(cartGroup.get("invalid"))) { throw new YshopException("有失效的商品请重新提交"); } - if(ObjectUtil.isEmpty(cartGroup.get("valid"))){ + if (ObjectUtil.isEmpty(cartGroup.get("valid"))) { throw new YshopException("请提交购买的商品"); } @@ -235,7 +212,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl 0) || (secKillId != null && secKillId > 0) - || (bargainId != null && bargainId > 0) ) { + if ((combinationId != null && combinationId > 0) || (secKillId != null && secKillId > 0) + || (bargainId != null && bargainId > 0)) { deduction = true; } //获取默认地址 YxUserAddress userAddress = userAddressService.getOne(Wrappers.lambdaQuery() - .eq(YxUserAddress::getUid,uid) - .eq(YxUserAddress::getIsDefault, ShopCommonEnum.DEFAULT_1.getValue()),false); + .eq(YxUserAddress::getUid, uid) + .eq(YxUserAddress::getIsDefault, ShopCommonEnum.DEFAULT_1.getValue()), false); - List cartInfo = (List)cartGroup.get("valid"); - PriceGroupDto priceGroup = this.getOrderPriceGroup(cartInfo,userAddress); + List cartInfo = (List) cartGroup.get("valid"); + PriceGroupDto priceGroup = this.getOrderPriceGroup(cartInfo, userAddress); //判断积分是否满足订单额度 - if(priceGroup.getTotalPrice().compareTo(new BigDecimal(other.getIntegralFull())) < 0) { + if (priceGroup.getTotalPrice().compareTo(new BigDecimal(other.getIntegralFull())) < 0) { enableIntegral = false; } - String cacheKey = this.cacheOrderInfo(uid,cartInfo, priceGroup,other); + String cacheKey = this.cacheOrderInfo(uid, cartInfo, priceGroup, other); //获取可用优惠券 @@ -276,7 +253,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl 0) || (seckillId != null && seckillId > 0) - || (bargainId != null && bargainId > 0) ) { + if ((combinationId != null && combinationId > 0) || (seckillId != null && seckillId > 0) + || (bargainId != null && bargainId > 0)) { couponId = ""; useIntegral = ""; } BigDecimal couponPrice = BigDecimal.ZERO; - if(StrUtil.isNotBlank(couponId) && !ShopConstants.YSHOP_ZERO.equals(couponId)){//使用优惠券 - YxStoreCouponUser couponUser = couponUserService.getCoupon(Integer.valueOf(couponId),uid); - if(couponUser == null) { + if (StrUtil.isNotBlank(couponId) && !ShopConstants.YSHOP_ZERO.equals(couponId)) {//使用优惠券 + YxStoreCouponUser couponUser = couponUserService.getCoupon(Integer.valueOf(couponId), uid); + if (couponUser == null) { throw new YshopException("使用优惠劵失败"); } - if(couponUser.getUseMinPrice().compareTo(payPrice) > 0){ + if (couponUser.getUseMinPrice().compareTo(payPrice) > 0) { throw new YshopException("不满足优惠劵的使用条件"); } - payPrice = NumberUtil.sub(payPrice,couponUser.getCouponPrice()); + payPrice = NumberUtil.sub(payPrice, couponUser.getCouponPrice()); couponPrice = couponUser.getCouponPrice(); } // 积分抵扣 BigDecimal deductionPrice = BigDecimal.ZERO; //积分抵扣金额 double usedIntegral = 0; //使用了多少积分 - if(StrUtil.isNotBlank(useIntegral) && ShopConstants.YSHOP_ONE.equals(useIntegral) - && userInfo.getIntegral().intValue() > 0){ + if (StrUtil.isNotBlank(useIntegral) && ShopConstants.YSHOP_ONE.equals(useIntegral) + && userInfo.getIntegral().intValue() > 0) { Double integralMax = Double.valueOf(cacheDTO.getOther().getIntegralMax()); BigDecimal integralFull = new BigDecimal(cacheDTO.getOther().getIntegralFull()); Double integralRatio = Double.valueOf(cacheDTO.getOther().getIntegralRatio()); - if(cacheDTO.getPriceGroup().getTotalPrice().compareTo(integralFull) >= 0){ + if (cacheDTO.getPriceGroup().getTotalPrice().compareTo(integralFull) >= 0) { Double userIntegral = userInfo.getIntegral().doubleValue(); - if(integralMax.intValue() > 0 && Double.compare(userIntegral,integralMax) >= 0) { + if (integralMax.intValue() > 0 && Double.compare(userIntegral, integralMax) >= 0) { userIntegral = integralMax; } deductionPrice = BigDecimal.valueOf(NumberUtil.mul(userIntegral, integralRatio)); - if(deductionPrice.compareTo(payPrice) < 0){ - payPrice = NumberUtil.sub(payPrice,deductionPrice); + if (deductionPrice.compareTo(payPrice) < 0) { + payPrice = NumberUtil.sub(payPrice, deductionPrice); usedIntegral = userIntegral; - }else{ + } else { deductionPrice = payPrice; payPrice = BigDecimal.ZERO; usedIntegral = NumberUtil.round(NumberUtil.div(deductionPrice, - BigDecimal.valueOf(integralRatio)),2).doubleValue(); + BigDecimal.valueOf(integralRatio)), 2).doubleValue(); } } } - if(payPrice.compareTo(BigDecimal.ZERO) <= 0) { + if (payPrice.compareTo(BigDecimal.ZERO) <= 0) { payPrice = BigDecimal.ZERO; } @@ -408,35 +385,35 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl cartInfo = cacheDTO.getCartInfo(); for (YxStoreCartQueryVo cart : cartInfo) { //检测库存 - yxStoreCartService.checkProductStock(uid,cart.getProductId(),cart.getCartNum(), + yxStoreCartService.checkProductStock(uid, cart.getProductId(), cart.getCartNum(), cart.getProductAttrUnique(), cart.getCombinationId(), - cart.getSeckillId(),cart.getBargainId()); + cart.getSeckillId(), cart.getBargainId()); combinationId = cart.getCombinationId(); seckillId = cart.getSeckillId(); @@ -473,42 +450,43 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl 0){ - this.decIntegral(userInfo,computeVo.getUsedIntegral(),computeVo.getDeductionPrice().doubleValue()); + if (computeVo.getUsedIntegral() > 0) { + this.decIntegral(userInfo, computeVo.getUsedIntegral(), computeVo.getDeductionPrice().doubleValue()); } //使用了优惠券扣优惠券 - if(computeVo.getCouponPrice().compareTo(BigDecimal.ZERO) > 0) { + if (computeVo.getCouponPrice().compareTo(BigDecimal.ZERO) > 0) { couponUserService.useCoupon(Integer.valueOf(param.getCouponId())); } @@ -558,28 +536,27 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpllambdaQuery() - .in(YxStoreCart::getId,cartIds)); + storeCartMapper.update(cartObj, Wrappers.lambdaQuery() + .in(YxStoreCart::getId, cartIds)); //删除缓存 - this.delCacheOrderInfo(uid,key); + this.delCacheOrderInfo(uid, key); //增加状态 - orderStatusService.create(storeOrder.getId(),OrderLogEnum.CREATE_ORDER.getValue(), + orderStatusService.create(storeOrder.getId(), OrderLogEnum.CREATE_ORDER.getValue(), OrderLogEnum.CREATE_ORDER.getDesc()); - //加入redis,30分钟自动取消 String redisKey = String.valueOf(StrUtil.format("{}{}", ShopConstants.REDIS_ORDER_OUTTIME_UNPAY, storeOrder.getId())); - redisTemplate.opsForValue().set(redisKey, storeOrder.getOrderId() , + redisTemplate.opsForValue().set(redisKey, storeOrder.getOrderId(), ShopConstants.ORDER_OUTTIME_UNPAY, TimeUnit.MINUTES); //使用MQ延时消息 @@ -598,28 +575,27 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpllambdaQuery() - .eq(YxStoreOrderCartInfo::getUnique,unique)); + public void orderComment(YxStoreOrderCartInfo orderCartInfo, YxUser user, String unique, String comment, String pics, String productScore, + String serviceScore) { - if(ObjectUtil.isEmpty(orderCartInfo)) { + if (ObjectUtil.isEmpty(orderCartInfo)) { throw new YshopException("评价产品不存在"); } int count = productReplyService.count(Wrappers.lambdaQuery() - .eq(YxStoreProductReply::getOid,orderCartInfo.getOid()) - .eq(YxStoreProductReply::getProductId,orderCartInfo.getProductId())); - if(count > 0) { + .eq(YxStoreProductReply::getOid, orderCartInfo.getOid()) + .eq(YxStoreProductReply::getProductId, orderCartInfo.getProductId())); + if (count > 0) { throw new YshopException("该产品已评价"); } @@ -640,81 +616,77 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl().eq(YxStoreProductReply::getOid, orderCartInfo.getOid())); //购买商品数量 int cartCount = storeOrderCartInfoService.count(new LambdaQueryWrapper().eq(YxStoreOrderCartInfo::getOid, orderCartInfo.getOid())); - if(replyCount==cartCount){ + if (replyCount == cartCount) { YxStoreOrder storeOrder = new YxStoreOrder(); storeOrder.setStatus(OrderInfoEnum.STATUS_3.getValue()); storeOrder.setId(orderCartInfo.getOid()); yxStoreOrderMapper.updateById(storeOrder); } - //增加状态 - orderStatusService.create(orderCartInfo.getOid(), - OrderLogEnum.EVAL_ORDER.getValue(), - OrderLogEnum.EVAL_ORDER.getDesc()); - } /** * 确认订单退款 + * * @param orderId 单号 - * @param price 金额 - * @param type ShopCommonEnum + * @param price 金额 + * @param type ShopCommonEnum */ @Override - public void orderRefund(String orderId,BigDecimal price,Integer type) { + public void orderRefund(String orderId, BigDecimal price, Integer type) { - YxStoreOrderQueryVo orderQueryVo = getOrderInfo(orderId,null); - if(ObjectUtil.isNull(orderQueryVo)) { + YxStoreOrderQueryVo orderQueryVo = getOrderInfo(orderId, null); + if (ObjectUtil.isNull(orderQueryVo)) { throw new YshopException("订单不存在"); } YxUserQueryVo userQueryVo = userService.getYxUserById(orderQueryVo.getUid()); - if(ObjectUtil.isNull(userQueryVo)) { + if (ObjectUtil.isNull(userQueryVo)) { throw new YshopException("用户不存在"); } - if(OrderInfoEnum.REFUND_STATUS_2.getValue().equals(orderQueryVo.getRefundStatus())){ + if (OrderInfoEnum.REFUND_STATUS_2.getValue().equals(orderQueryVo.getRefundStatus())) { throw new YshopException("订单已经退款了哦!"); } - if(orderQueryVo.getPayPrice().compareTo(price) < 0) { + if (orderQueryVo.getPayPrice().compareTo(price) < 0) { throw new YshopException("退款金额不正确"); } YxStoreOrder storeOrder = new YxStoreOrder(); //修改状态 storeOrder.setId(orderQueryVo.getId()); - if(ShopCommonEnum.AGREE_2.getValue().equals(type)){ + if (ShopCommonEnum.AGREE_2.getValue().equals(type)) { storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue()); yxStoreOrderMapper.updateById(storeOrder); return; } //根据支付类型不同退款不同 - if(PayTypeEnum.YUE.getValue().equals(orderQueryVo.getPayType())){ + if (PayTypeEnum.YUE.getValue().equals(orderQueryVo.getPayType())) { storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_2.getValue()); storeOrder.setRefundPrice(price); yxStoreOrderMapper.updateById(storeOrder); //退款到余额 - userService.incMoney(orderQueryVo.getUid(),price); + userService.incMoney(orderQueryVo.getUid(), price); //增加流水 - billService.income(orderQueryVo.getUid(),"商品退款",BillDetailEnum.CATEGORY_1.getValue(), + billService.income(orderQueryVo.getUid(), "商品退款", BillDetailEnum.CATEGORY_1.getValue(), BillDetailEnum.TYPE_5.getValue(), price.doubleValue(), - NumberUtil.add(price,userQueryVo.getNowMoney()).doubleValue(), - "订单退款到余额"+price+"元",orderQueryVo.getId().toString()); + NumberUtil.add(price, userQueryVo.getNowMoney()).doubleValue(), + "订单退款到余额" + price + "元", orderQueryVo.getId().toString()); this.retrunStock(orderQueryVo.getOrderId()); - }else if(PayTypeEnum.INTEGRAL.getValue().equals(orderQueryVo.getPayType())){ + } else if (PayTypeEnum.INTEGRAL.getValue().equals(orderQueryVo.getPayType())) { storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_2.getValue()); storeOrder.setRefundPrice(price); yxStoreOrderMapper.updateById(storeOrder); - orderStatusService.create(orderQueryVo.getId(),OrderLogEnum.ORDER_EDIT.getValue(),"退款给用户:"+orderQueryVo.getPayIntegral() +"分"); + orderStatusService.create(orderQueryVo.getId(), OrderLogEnum.ORDER_EDIT.getValue(), "退款给用户:" + orderQueryVo.getPayIntegral() + "分"); this.retrunStock(orderQueryVo.getOrderId()); } - orderStatusService.create(orderQueryVo.getId(),OrderLogEnum.REFUND_ORDER_SUCCESS.getValue(),"退款给用户:"+price +"元"); + orderStatusService.create(orderQueryVo.getId(), OrderLogEnum.REFUND_ORDER_SUCCESS.getValue(), "退款给用户:" + price + "元"); TemplateBean templateBean = TemplateBean.builder() .orderId(orderQueryVo.getOrderId()) @@ -724,7 +696,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl().eq(YxExpress::getName,deliveryName)); - if(ObjectUtil.isNull(expressQueryVo)) { + YxExpress expressQueryVo = expressService.getOne(new LambdaQueryWrapper().eq(YxExpress::getName, deliveryName)); + if (ObjectUtil.isNull(expressQueryVo)) { throw new YshopException("请后台先添加快递公司"); } //判断拼团产品 - if(orderQueryVo.getPinkId() != null && orderQueryVo.getPinkId() >0 ){ + if (orderQueryVo.getPinkId() != null && orderQueryVo.getPinkId() > 0) { YxStorePink pink = pinkService.getById(orderQueryVo.getPinkId()); - if(!OrderInfoEnum.PINK_STATUS_2.getValue().equals(pink.getStatus())){ + if (!OrderInfoEnum.PINK_STATUS_2.getValue().equals(pink.getStatus())) { throw new YshopException("拼团未成功不能发货"); } } @@ -778,8 +751,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl().eq(YxExpress::getName,deliveryName)); - if(ObjectUtil.isNull(expressQueryVo)) { + YxExpress expressQueryVo = expressService.getOne(new LambdaQueryWrapper().eq(YxExpress::getName, deliveryName)); + if (ObjectUtil.isNull(expressQueryVo)) { throw new YshopException("请后台先添加快递公司"); } @@ -840,23 +813,24 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpllambdaQuery() - .eq(YxStoreOrder::getVerifyCode,verifyCode) - .eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue())); - if(order == null) { + .eq(YxStoreOrder::getVerifyCode, verifyCode) + .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue())); + if (order == null) { throw new YshopException("核销的订单不存在或未支付或已退款"); } - if(uid != null){ - boolean checkStatus = systemStoreStaffService.checkStatus(uid,order.getStoreId()); - if(!checkStatus) { + if (uid != null) { + boolean checkStatus = systemStoreStaffService.checkStatus(uid, order.getStoreId()); + if (!checkStatus) { throw new YshopException("您没有当前店铺核销权限"); } } - if(!OrderInfoEnum.STATUS_0.getValue().equals(order.getStatus())) { + if (!OrderInfoEnum.STATUS_0.getValue().equals(order.getStatus())) { throw new YshopException("订单已经核销"); } - if(order.getCombinationId() != null && order.getCombinationId() > 0 - && order.getPinkId() != null && order.getPinkId() > 0){ + if (order.getCombinationId() != null && order.getCombinationId() > 0 + && order.getPinkId() != null && order.getPinkId() > 0) { YxStorePink storePink = storePinkService.getById(order.getPinkId()); - if(!OrderInfoEnum.PINK_STATUS_2.getValue().equals(storePink.getStatus())){ + if (!OrderInfoEnum.PINK_STATUS_2.getValue().equals(storePink.getStatus())) { throw new YshopException("拼团订单暂未成功无法核销"); } } - YxStoreOrderQueryVo orderQueryVo = generator.convert(order,YxStoreOrderQueryVo.class); - if(OrderInfoEnum.CONFIRM_STATUS_0.getValue().equals(isConfirm)){ + YxStoreOrderQueryVo orderQueryVo = generator.convert(order, YxStoreOrderQueryVo.class); + if (OrderInfoEnum.CONFIRM_STATUS_0.getValue().equals(isConfirm)) { return orderQueryVo; } @@ -1028,7 +1003,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl orderList(Long uid, int type, int page, int limit) { - LambdaQueryWrapper wrapper= new LambdaQueryWrapper<>(); - if(uid != null) { - wrapper.eq(YxStoreOrder::getUid,uid); + public Map orderList(Long uid, int type, int page, int limit) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapper.eq(YxStoreOrder::getUid, uid); } wrapper.orderByDesc(YxStoreOrder::getId); - switch (OrderStatusEnum.toType(type)){ + switch (OrderStatusEnum.toType(type)) { case STATUS__1: break; //未支付 case STATUS_0: - wrapper.eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_0.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()) - .eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_0.getValue()); + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_0.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_0.getValue()); break; //待发货 case STATUS_1: - wrapper.eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()) - .eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_0.getValue()); + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_0.getValue()); break; //待收货 case STATUS_2: - wrapper.eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()) - .eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_1.getValue()); + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_1.getValue()); break; //待评价 case STATUS_3: - wrapper.eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()) - .eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_2.getValue()); + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_2.getValue()); break; //已完成 case STATUS_4: - wrapper.eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()) - .eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_3.getValue()); + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_3.getValue()); break; //退款中 case STATUS_MINUS_1: - wrapper.eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_1.getValue()); + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_1.getValue()); break; //已退款 case STATUS_MINUS_2: - wrapper.eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_0.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_2.getValue()); + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_0.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_2.getValue()); break; //退款 case STATUS_MINUS_3: - String[] strs = {"1","2"}; - wrapper.eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) + String[] strs = {"1", "2"}; + wrapper.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) .in(YxStoreOrder::getRefundStatus, Arrays.asList(strs)); break; default: } Page pageModel = new Page<>(page, limit); - IPage pageList = yxStoreOrderMapper.selectPage(pageModel,wrapper); - List list = generator.convert(pageList.getRecords(),YxStoreOrderQueryVo.class); - Map map = new HashMap<>(); - map.put("list",list.stream() + IPage pageList = yxStoreOrderMapper.selectPage(pageModel, wrapper); + List list = generator.convert(pageList.getRecords(), YxStoreOrderQueryVo.class); + Map map = new HashMap<>(); + map.put("list", list.stream() .map(this::handleOrder) .collect(Collectors.toList())); - map.put("total",pageList.getTotal()); - map.put("totalPage",pageList.getPages()); + map.put("total", pageList.getTotal()); + map.put("totalPage", pageList.getPages()); return map; } /** * chart图标统计 + * * @param cate * @param type * @return */ - // @Override + // @Override @Deprecated /** - public Map chartCount(int cate,int type) { - int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date())); - int yesterday = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(DateUtil. - yesterday())); - int lastWeek = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(DateUtil.lastWeek())); - int nowMonth = OrderUtil.dateToTimestampT(DateUtil - .beginOfMonth(new Date())); - double price = 0d; - List list = null; - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq("paid",1).eq("refund_status",0).eq("is_del",0); + public Map chartCount(int cate,int type) { + int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date())); + int yesterday = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(DateUtil. + yesterday())); + int lastWeek = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(DateUtil.lastWeek())); + int nowMonth = OrderUtil.dateToTimestampT(DateUtil + .beginOfMonth(new Date())); + double price = 0d; + List list = null; + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq("paid",1).eq("refund_status",0).eq("is_del",0); - switch (OrderCountEnum.toType(cate)){ - case TODAY: //今天 - wrapper.ge("pay_time",today); - break; - case YESTERDAY: //昨天 - wrapper.lt("pay_time",today).ge("pay_time",yesterday); - break; - case WEEK: //上周 - wrapper.ge("pay_time",lastWeek); - break; - case MONTH: //本月 - wrapper.ge("pay_time",nowMonth); - break; - } - if(type == 1){ - list = yxStoreOrderMapper.chartList(wrapper); - price = yxStoreOrderMapper.todayPrice(wrapper); - }else{ - list = yxStoreOrderMapper.chartListT(wrapper); - price = yxStoreOrderMapper.selectCount(wrapper).doubleValue(); - } + switch (OrderCountEnum.toType(cate)){ + case TODAY: //今天 + wrapper.ge("pay_time",today); + break; + case YESTERDAY: //昨天 + wrapper.lt("pay_time",today).ge("pay_time",yesterday); + break; + case WEEK: //上周 + wrapper.ge("pay_time",lastWeek); + break; + case MONTH: //本月 + wrapper.ge("pay_time",nowMonth); + break; + } + if(type == 1){ + list = yxStoreOrderMapper.chartList(wrapper); + price = yxStoreOrderMapper.todayPrice(wrapper); + }else{ + list = yxStoreOrderMapper.chartListT(wrapper); + price = yxStoreOrderMapper.selectCount(wrapper).doubleValue(); + } - Map map = new LinkedHashMap<>(); - map.put("chart",list); - map.put("time",price); - return map; - } - **/ + Map map = new LinkedHashMap<>(); + map.put("chart",list); + map.put("time",price); + return map; + } + **/ /** * 获取 今日 昨日 本月 订单金额 @@ -1240,43 +1218,43 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl wrapperOne = new LambdaQueryWrapper<>(); + LambdaQueryWrapper wrapperOne = new LambdaQueryWrapper<>(); wrapperOne - .ge(YxStoreOrder::getPayTime,today) - .eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()); + .ge(YxStoreOrder::getPayTime, today) + .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()); orderTimeDataVo.setTodayPrice(yxStoreOrderMapper.todayPrice(wrapperOne)); //今日订单数 orderTimeDataVo.setTodayCount(yxStoreOrderMapper.selectCount(wrapperOne)); //昨日成交额 - LambdaQueryWrapper wrapperTwo = new LambdaQueryWrapper<>(); + LambdaQueryWrapper wrapperTwo = new LambdaQueryWrapper<>(); wrapperTwo - .lt(YxStoreOrder::getPayTime,today) - .ge(YxStoreOrder::getPayTime,yesterday) - .eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()); + .lt(YxStoreOrder::getPayTime, today) + .ge(YxStoreOrder::getPayTime, yesterday) + .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()); orderTimeDataVo.setProPrice(yxStoreOrderMapper.todayPrice(wrapperTwo)); //昨日订单数 orderTimeDataVo.setProCount(yxStoreOrderMapper.selectCount(wrapperTwo)); //本月成交额 - LambdaQueryWrapper wrapperThree = new LambdaQueryWrapper<>(); + LambdaQueryWrapper wrapperThree = new LambdaQueryWrapper<>(); wrapperThree - .ge(YxStoreOrder::getPayTime,nowMonth) - .eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()); + .ge(YxStoreOrder::getPayTime, nowMonth) + .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()); orderTimeDataVo.setMonthPrice(yxStoreOrderMapper.todayPrice(wrapperThree)); //本月订单数 orderTimeDataVo.setMonthCount(yxStoreOrderMapper.selectCount(wrapperThree)); //上周成交额 - LambdaQueryWrapper wrapperLastWeek = new LambdaQueryWrapper<>(); + LambdaQueryWrapper wrapperLastWeek = new LambdaQueryWrapper<>(); wrapperLastWeek - .lt(YxStoreOrder::getPayTime,today) - .ge(YxStoreOrder::getPayTime,lastWeek) - .eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()); + .lt(YxStoreOrder::getPayTime, today) + .ge(YxStoreOrder::getPayTime, lastWeek) + .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()); orderTimeDataVo.setLastWeekPrice(yxStoreOrderMapper.todayPrice(wrapperLastWeek)); //上周订单数 orderTimeDataVo.setLastWeekCount(yxStoreOrderMapper.selectCount(wrapperLastWeek)); @@ -1287,7 +1265,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl0 取用户 否则取所有 * @return UserOrderCountVo */ @@ -1306,11 +1286,11 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl wrapperOne = new LambdaQueryWrapper<>(); - if(uid != null) { - wrapperOne.eq(YxStoreOrder::getUid,uid); + LambdaQueryWrapper wrapperOne = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperOne.eq(YxStoreOrder::getUid, uid); } - wrapperOne.eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()) + wrapperOne.eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()); Integer orderCount = yxStoreOrderMapper.selectCount(wrapperOne); @@ -1318,63 +1298,63 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl wrapperTwo = new LambdaQueryWrapper<>(); - if(uid != null) { - wrapperTwo.eq(YxStoreOrder::getUid,uid); + LambdaQueryWrapper wrapperTwo = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperTwo.eq(YxStoreOrder::getUid, uid); } wrapperTwo.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_0.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()) - .eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_0.getValue()); + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_0.getValue()); Integer unpaidCount = yxStoreOrderMapper.selectCount(wrapperTwo); //订单待发货 数量 - LambdaQueryWrapper wrapperThree = new LambdaQueryWrapper<>(); - if(uid != null) { - wrapperThree.eq(YxStoreOrder::getUid,uid); + LambdaQueryWrapper wrapperThree = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperThree.eq(YxStoreOrder::getUid, uid); } wrapperThree.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()) - .eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_0.getValue()); + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_0.getValue()); Integer unshippedCount = yxStoreOrderMapper.selectCount(wrapperThree); //订单待收货 数量 - LambdaQueryWrapper wrapperFour = new LambdaQueryWrapper<>(); - if(uid != null) { - wrapperFour.eq(YxStoreOrder::getUid,uid); + LambdaQueryWrapper wrapperFour = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperFour.eq(YxStoreOrder::getUid, uid); } wrapperFour.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()) - .eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_1.getValue()); + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_1.getValue()); Integer receivedCount = yxStoreOrderMapper.selectCount(wrapperFour); //订单待评价 数量 - LambdaQueryWrapper wrapperFive = new LambdaQueryWrapper<>(); - if(uid != null) { - wrapperFive.eq(YxStoreOrder::getUid,uid); + LambdaQueryWrapper wrapperFive = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperFive.eq(YxStoreOrder::getUid, uid); } wrapperFive.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()) - .eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_2.getValue()); + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_2.getValue()); Integer evaluatedCount = yxStoreOrderMapper.selectCount(wrapperFive); //订单已完成 数量 - LambdaQueryWrapper wrapperSix= new LambdaQueryWrapper<>(); - if(uid != null) { - wrapperSix.eq(YxStoreOrder::getUid,uid); + LambdaQueryWrapper wrapperSix = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperSix.eq(YxStoreOrder::getUid, uid); } wrapperSix.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getRefundStatus,OrderInfoEnum.REFUND_STATUS_0.getValue()) - .eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_3.getValue()); + .eq(YxStoreOrder::getRefundStatus, OrderInfoEnum.REFUND_STATUS_0.getValue()) + .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_3.getValue()); Integer completeCount = yxStoreOrderMapper.selectCount(wrapperSix); //订单退款 - LambdaQueryWrapper wrapperSeven= new LambdaQueryWrapper<>(); - if(uid != null) { - wrapperSeven.eq(YxStoreOrder::getUid,uid); + LambdaQueryWrapper wrapperSeven = new LambdaQueryWrapper<>(); + if (uid != null) { + wrapperSeven.eq(YxStoreOrder::getUid, uid); } - String[] strArr = {"1","2"}; + String[] strArr = {"1", "2"}; wrapperSeven.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) - .in(YxStoreOrder::getRefundStatus,Arrays.asList(strArr)); + .in(YxStoreOrder::getRefundStatus, Arrays.asList(strArr)); Integer refundCount = yxStoreOrderMapper.selectCount(wrapperSeven); @@ -1392,18 +1372,19 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(YxStoreOrderCartInfo::getOid,order.getId()); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(YxStoreOrderCartInfo::getOid, order.getId()); List cartInfos = orderCartInfoService.list(wrapper); List cartInfo = cartInfos.stream() .map(cart -> { - YxStoreCartQueryVo cartQueryVo = JSON.parseObject(cart.getCartInfo(),YxStoreCartQueryVo.class); + YxStoreCartQueryVo cartQueryVo = JSON.parseObject(cart.getCartInfo(), YxStoreCartQueryVo.class); cartQueryVo.setUnique(cart.getUnique()); cartQueryVo.setIsReply(productReplyService.replyCount(cart.getUnique())); return cartQueryVo; @@ -1412,45 +1393,45 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl 0){ - if(pinkService.pinkIngCount(order.getPinkId()) > 0){ + if (order.getPinkId() > 0) { + if (pinkService.pinkIngCount(order.getPinkId()) > 0) { statusDTO.set_class("state-nfh"); statusDTO.set_msg("待其他人参加拼团"); statusDTO.set_type("1"); statusDTO.set_title("拼团中"); - }else{ + } else { statusDTO.set_class("state-nfh"); statusDTO.set_msg("商家未发货,请耐心等待"); statusDTO.set_type("1"); statusDTO.set_title("未发货"); } - }else{ - if(OrderInfoEnum.SHIPPIING_TYPE_1.getValue().equals(order.getShippingType())){ + } else { + if (OrderInfoEnum.SHIPPIING_TYPE_1.getValue().equals(order.getShippingType())) { statusDTO.set_class("state-nfh"); statusDTO.set_msg("商家未发货,请耐心等待"); statusDTO.set_type("1"); statusDTO.set_title("未发货"); - }else{ + } else { statusDTO.set_class("state-nfh"); statusDTO.set_msg("待核销,请到核销点进行核销"); statusDTO.set_type("1"); @@ -1458,28 +1439,28 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(YxStoreOrder::getOrderId,orderId); + wrapper.eq(YxStoreOrder::getOrderId, orderId); YxStoreOrder storeOrder = new YxStoreOrder(); storeOrder.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue()); storeOrder.setPayType(payType); storeOrder.setPayTime(new Date()); - yxStoreOrderMapper.update(storeOrder,wrapper); + yxStoreOrderMapper.update(storeOrder, wrapper); //增加用户购买次数 userService.incPayCount(orderInfo.getUid()); //增加状态 - orderStatusService.create(orderInfo.getId(),OrderLogEnum.PAY_ORDER_SUCCESS.getValue(), + orderStatusService.create(orderInfo.getId(), OrderLogEnum.PAY_ORDER_SUCCESS.getValue(), OrderLogEnum.PAY_ORDER_SUCCESS.getDesc()); //拼团 - if(orderInfo.getCombinationId() > 0) { + if (orderInfo.getCombinationId() > 0) { pinkService.createPink(orderInfo); } //砍价 - if(orderInfo.getBargainId() > 0) { + if (orderInfo.getBargainId() > 0) { storeBargainUserService.setBargainUserStatus(orderInfo.getBargainId(), orderInfo.getUid()); } YxUser userInfo = userService.getById(orderInfo.getUid()); //增加流水 String payTypeMsg = PayTypeEnum.WEIXIN.getDesc(); - if(PayTypeEnum.YUE.getValue().equals(payType)) { + if (PayTypeEnum.YUE.getValue().equals(payType)) { payTypeMsg = PayTypeEnum.YUE.getDesc(); } billService.expend(userInfo.getUid(), "购买商品", @@ -1535,7 +1517,6 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl{ - if(cart.getProductInfo().getIsIntegral()==0){ + orderInfo = handleOrder(orderInfo); + orderInfo.getCartInfo().forEach(cart -> { + if (cart.getProductInfo().getIsIntegral() == 0) { throw new YshopException("该商品不为积分商品"); } }); YxUser userInfo = userService.getById(uid); - if(userInfo.getIntegral().compareTo(orderInfo.getPayIntegral()) < 0){ + if (userInfo.getIntegral().compareTo(orderInfo.getPayIntegral()) < 0) { throw new YshopException("积分不足"); } @@ -1646,38 +1627,40 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); + public YxStoreOrderQueryVo getOrderInfo(String unique, Long uid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.and( - i->i.eq(YxStoreOrder::getOrderId,unique).or().eq(YxStoreOrder::getUnique,unique).or() - .eq(YxStoreOrder::getExtendOrderId,unique)); - if(uid != null) { - wrapper.eq(YxStoreOrder::getUid,uid); + i -> i.eq(YxStoreOrder::getOrderId, unique).or().eq(YxStoreOrder::getUnique, unique).or() + .eq(YxStoreOrder::getExtendOrderId, unique)); + if (uid != null) { + wrapper.eq(YxStoreOrder::getUid, uid); } - return generator.convert(yxStoreOrderMapper.selectOne(wrapper),YxStoreOrderQueryVo.class); + return generator.convert(yxStoreOrderMapper.selectOne(wrapper), YxStoreOrderQueryVo.class); } /** * 奖励积分 + * * @param order 订单 */ private void gainUserIntegral(YxStoreOrderQueryVo order) { - if( order.getGainIntegral().compareTo(BigDecimal.ZERO) > 0){ + if (order.getGainIntegral().compareTo(BigDecimal.ZERO) > 0) { YxUser user = userService.getById(order.getUid()); BigDecimal newIntegral = NumberUtil.add(user.getIntegral(), order.getGainIntegral()); @@ -1686,16 +1669,17 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl cartInfo) { @@ -1703,17 +1687,17 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl 0){ - productService.decProductStock(storeCartVO.getCartNum(),storeCartVO.getProductId(), - storeCartVO.getProductAttrUnique(),combinationId,ProductTypeEnum.COMBINATION.getValue()); - }else if(seckillId != null && seckillId > 0){ - productService.decProductStock(storeCartVO.getCartNum(),storeCartVO.getProductId(), - storeCartVO.getProductAttrUnique(),seckillId, ProductTypeEnum.SECKILL.getValue()); - }else if(bargainId != null && bargainId > 0){ - storeBargainService.decStockIncSales(storeCartVO.getCartNum(),bargainId); + if (combinationId != null && combinationId > 0) { + productService.decProductStock(storeCartVO.getCartNum(), storeCartVO.getProductId(), + storeCartVO.getProductAttrUnique(), combinationId, ProductTypeEnum.COMBINATION.getValue()); + } else if (seckillId != null && seckillId > 0) { + productService.decProductStock(storeCartVO.getCartNum(), storeCartVO.getProductId(), + storeCartVO.getProductAttrUnique(), seckillId, ProductTypeEnum.SECKILL.getValue()); + } else if (bargainId != null && bargainId > 0) { + storeBargainService.decStockIncSales(storeCartVO.getCartNum(), bargainId); } else { - productService.decProductStock(storeCartVO.getCartNum(),storeCartVO.getProductId(), - storeCartVO.getProductAttrUnique(), 0L,""); + productService.decProductStock(storeCartVO.getCartNum(), storeCartVO.getProductId(), + storeCartVO.getProductAttrUnique(), 0L, ""); } } } @@ -1721,9 +1705,10 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl cartInfo){ + private BigDecimal getGainIntegral(List cartInfo) { BigDecimal gainIntegral = BigDecimal.ZERO; for (YxStoreCartQueryVo cart : cartInfo) { - if(cart.getCombinationId() >0 || cart.getSeckillId() > 0 || cart.getBargainId() > 0) { + if (cart.getCombinationId() > 0 || cart.getSeckillId() > 0 || cart.getBargainId() > 0) { continue; } BigDecimal cartInfoGainIntegral = BigDecimal.ZERO; Double gain = cart.getProductInfo().getGiveIntegral().doubleValue(); - if(gain > 0){ - cartInfoGainIntegral = NumberUtil.round(NumberUtil.mul(cart.getCartNum(),gain),2); + if (gain > 0) { + cartInfoGainIntegral = NumberUtil.round(NumberUtil.mul(cart.getCartNum(), gain), 2); } - gainIntegral = NumberUtil.add(gainIntegral,cartInfoGainIntegral); + gainIntegral = NumberUtil.add(gainIntegral, cartInfoGainIntegral); } return gainIntegral; } @@ -1756,35 +1742,36 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl 0){ + if (order.getCouponId() != null && order.getCouponId() > 0) { YxStoreCouponUser couponUser = couponUserService .getOne(Wrappers.lambdaQuery() - .eq(YxStoreCouponUser::getId,order.getCouponId()) - .eq(YxStoreCouponUser::getStatus,CouponEnum.STATUS_1.getValue()) - .eq(YxStoreCouponUser::getUid,order.getUid())); + .eq(YxStoreCouponUser::getId, order.getCouponId()) + .eq(YxStoreCouponUser::getStatus, CouponEnum.STATUS_1.getValue()) + .eq(YxStoreCouponUser::getUid, order.getUid())); - if(ObjectUtil.isNotNull(couponUser)){ + if (ObjectUtil.isNotNull(couponUser)) { YxStoreCouponUser storeCouponUser = new YxStoreCouponUser(); storeCouponUser.setStatus(CouponEnum.STATUS_0.getValue()); storeCouponUser.setUseTime(null); - couponUserService.update(storeCouponUser,Wrappers.lambdaQuery() - .eq(YxStoreCouponUser::getId,order.getCouponId()) - .eq(YxStoreCouponUser::getUid,order.getUid())); + couponUserService.update(storeCouponUser, Wrappers.lambdaQuery() + .eq(YxStoreCouponUser::getId, order.getCouponId()) + .eq(YxStoreCouponUser::getUid, order.getUid())); } } @@ -1792,36 +1779,37 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl wrapper= new LambdaQueryWrapper<>(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(YxStoreOrderCartInfo::getCartId, Arrays.asList(order.getCartId().split(","))); - List cartInfoList = orderCartInfoService.list(wrapper); + List cartInfoList = orderCartInfoService.list(wrapper); for (YxStoreOrderCartInfo cartInfo : cartInfoList) { YxStoreCartQueryVo cart = JSONObject.parseObject(cartInfo.getCartInfo() - ,YxStoreCartQueryVo.class); - if(order.getCombinationId() != null && order.getCombinationId() > 0){//拼团 - productService.incProductStock(cart.getCartNum(),cart.getProductId(),cart.getProductAttrUnique(),order.getCombinationId(),ProductTypeEnum.COMBINATION.getValue()); - }else if(order.getSeckillId() != null && order.getSeckillId() > 0){//秒杀 - productService.incProductStock(cart.getCartNum(),cart.getProductId(),cart.getProductAttrUnique(),order.getSeckillId(),ProductTypeEnum.SECKILL.getValue()); - }else if(order.getBargainId() != null && order.getBargainId() > 0){//砍价 - storeBargainService.incStockDecSales(cart.getCartNum(),order.getBargainId()); - }else{ - productService.incProductStock(cart.getCartNum(),cart.getProductId() - ,cart.getProductAttrUnique(),0L,null); + , YxStoreCartQueryVo.class); + if (order.getCombinationId() != null && order.getCombinationId() > 0) {//拼团 + productService.incProductStock(cart.getCartNum(), cart.getProductId(), cart.getProductAttrUnique(), order.getCombinationId(), ProductTypeEnum.COMBINATION.getValue()); + } else if (order.getSeckillId() != null && order.getSeckillId() > 0) {//秒杀 + productService.incProductStock(cart.getCartNum(), cart.getProductId(), cart.getProductAttrUnique(), order.getSeckillId(), ProductTypeEnum.SECKILL.getValue()); + } else if (order.getBargainId() != null && order.getBargainId() > 0) {//砍价 + storeBargainService.incStockDecSales(cart.getCartNum(), order.getBargainId()); + } else { + productService.incProductStock(cart.getCartNum(), cart.getProductId() + , cart.getProductAttrUnique(), 0L, null); } } @@ -1829,47 +1817,48 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl0){ + if (order.getPayIntegral().compareTo(BigDecimal.ZERO) > 0) { order.setUseIntegral(order.getPayIntegral()); } - if(order.getUseIntegral().compareTo(BigDecimal.ZERO) <= 0) { + if (order.getUseIntegral().compareTo(BigDecimal.ZERO) <= 0) { return; } - if(!OrderStatusEnum.STATUS_MINUS_2.getValue().equals(order.getStatus()) + if (!OrderStatusEnum.STATUS_MINUS_2.getValue().equals(order.getStatus()) && !OrderInfoEnum.REFUND_STATUS_2.getValue().equals(order.getRefundStatus()) - && order.getBackIntegral().compareTo(BigDecimal.ZERO) > 0){ + && order.getBackIntegral().compareTo(BigDecimal.ZERO) > 0) { return; } YxUser yxUser = userService.getById(order.getUid()); //增加积分 - BigDecimal newIntegral = NumberUtil.add(order.getUseIntegral(),yxUser.getIntegral()); + BigDecimal newIntegral = NumberUtil.add(order.getUseIntegral(), yxUser.getIntegral()); yxUser.setIntegral(newIntegral); userService.updateById(yxUser); //增加流水 - billService.income(yxUser.getUid(),"积分回退",BillDetailEnum.CATEGORY_2.getValue(), + billService.income(yxUser.getUid(), "积分回退", BillDetailEnum.CATEGORY_2.getValue(), BillDetailEnum.TYPE_8.getValue(), order.getUseIntegral().doubleValue(), newIntegral.doubleValue(), - "购买商品失败,回退积分"+order.getUseIntegral(),order.getId().toString()); + "购买商品失败,回退积分" + order.getUseIntegral(), order.getId().toString()); //更新回退积分 YxStoreOrder storeOrder = new YxStoreOrder(); @@ -1880,13 +1869,14 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl cartInfo, PriceGroupDto priceGroup, OtherDto other) { @@ -1924,17 +1916,18 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl cartInfo,YxUserAddress userAddress) { + private PriceGroupDto getOrderPriceGroup(List cartInfo, YxUserAddress userAddress) { BigDecimal storePostage = BigDecimal.ZERO; String storeFreePostageStr = systemConfigService.getData(SystemConfigConstants.STORE_FREE_POSTAGE);//满额包邮 BigDecimal storeFreePostage = BigDecimal.ZERO; - if(NumberUtil.isNumber(storeFreePostageStr) && StrUtil.isNotBlank(storeFreePostageStr)) { + if (NumberUtil.isNumber(storeFreePostageStr) && StrUtil.isNotBlank(storeFreePostageStr)) { storeFreePostage = new BigDecimal(storeFreePostageStr); } @@ -1942,15 +1935,15 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl cartInfo,YxUserAddress userAddress){ + private BigDecimal handlePostage(List cartInfo, YxUserAddress userAddress) { BigDecimal storePostage = BigDecimal.ZERO; - if(userAddress != null){ - if(userAddress.getCityId() == null) { + if (userAddress != null) { + if (userAddress.getCityId() == null) { return storePostage; } //城市包括默认 @@ -1992,58 +1986,54 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl shippingTemplatesList = shippingTemplatesService .list(Wrappers.lambdaQuery() - .in(YxShippingTemplates::getId,tempIdS)); + .in(YxShippingTemplates::getId, tempIdS)); //获取运费模板区域列表按照城市排序 List shippingTemplatesRegionList = shippingTemplatesRegionService .list(Wrappers.lambdaQuery() - .in(YxShippingTemplatesRegion::getTempId,tempIdS) - .in(YxShippingTemplatesRegion::getCityId,citys) + .in(YxShippingTemplatesRegion::getTempId, tempIdS) + .in(YxShippingTemplatesRegion::getCityId, citys) .orderByAsc(YxShippingTemplatesRegion::getCityId)); //提取运费模板类型 - Map shippingTemplatesMap = shippingTemplatesList + Map shippingTemplatesMap = shippingTemplatesList .stream() .collect(Collectors.toMap(YxShippingTemplates::getId, YxShippingTemplates::getType)); //提取运费模板有相同值覆盖 - Map shippingTemplatesRegionMap = + Map shippingTemplatesRegionMap = shippingTemplatesRegionList.stream() .collect(Collectors.toMap(YxShippingTemplatesRegion::getTempId, - YxShippingTemplatesRegion->YxShippingTemplatesRegion, - (key1 , key2)-> key2)); + YxShippingTemplatesRegion -> YxShippingTemplatesRegion, + (key1, key2) -> key2)); Map templateDTOMap = new HashMap<>(); - for (YxStoreCartQueryVo storeCartVO : cartInfo){ + for (YxStoreCartQueryVo storeCartVO : cartInfo) { Integer tempId = storeCartVO.getProductInfo().getTempId(); //处理拼团等营销商品没有设置运费模板 - if(tempId == null) { + if (tempId == null) { return storePostage; } //根据模板类型获取相应的数量 double num = 0d; - if(ShippingTempEnum.TYPE_1.getValue().equals(shippingTemplatesMap.get(tempId))){ + if (ShippingTempEnum.TYPE_1.getValue().equals(shippingTemplatesMap.get(tempId))) { num = storeCartVO.getCartNum().doubleValue(); - }else if(ShippingTempEnum.TYPE_2.getValue().equals(shippingTemplatesMap.get(tempId))){ + } else if (ShippingTempEnum.TYPE_2.getValue().equals(shippingTemplatesMap.get(tempId))) { num = NumberUtil.mul(storeCartVO.getCartNum(), storeCartVO.getProductInfo().getAttrInfo().getWeight()).doubleValue(); - }else if(ShippingTempEnum.TYPE_3.getValue().equals(shippingTemplatesMap.get(tempId))){ + } else if (ShippingTempEnum.TYPE_3.getValue().equals(shippingTemplatesMap.get(tempId))) { num = NumberUtil.mul(storeCartVO.getCartNum(), storeCartVO.getProductInfo().getAttrInfo().getVolume()).doubleValue(); } YxShippingTemplatesRegion shippingTemplatesRegion = shippingTemplatesRegionMap.get(tempId); BigDecimal price = NumberUtil.round(NumberUtil.mul(storeCartVO.getCartNum(), - storeCartVO.getTruePrice()),2) ; - if(!templateDTOMap.containsKey(tempId)){ + storeCartVO.getTruePrice()), 2); + if (!templateDTOMap.containsKey(tempId)) { TemplateDto templateDTO = TemplateDto.builder() .number(num) .price(price) @@ -2054,62 +2044,61 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl entry : templateDTOMap.entrySet()){ + for (Map.Entry entry : templateDTOMap.entrySet()) { Integer mapKey = entry.getKey(); TemplateDto mapValue = entry.getValue(); int count = shippingTemplatesFreeService.count(Wrappers.lambdaQuery() - .eq(YxShippingTemplatesFree::getTempId,mapValue.getTempId()) - .eq(YxShippingTemplatesFree::getCityId,mapValue.getCityId()) - .le(YxShippingTemplatesFree::getNumber,mapValue.getNumber()) - .le(YxShippingTemplatesFree::getPrice,mapValue.getPrice())); + .eq(YxShippingTemplatesFree::getTempId, mapValue.getTempId()) + .eq(YxShippingTemplatesFree::getCityId, mapValue.getCityId()) + .le(YxShippingTemplatesFree::getNumber, mapValue.getNumber()) + .le(YxShippingTemplatesFree::getPrice, mapValue.getPrice())); //满足包邮条件剔除 - if(count > 0) { + if (count > 0) { templateDTOMap.remove(mapKey); } } //处理区域邮费 boolean isFirst = true; //用来是否多个产品的标识 false表示数量大于1 - for(TemplateDto templateDTO : templateDTOMap.values()){ - if(isFirst){//首件 + for (TemplateDto templateDTO : templateDTOMap.values()) { + if (isFirst) {//首件 //只满足首件 - if(Double.compare(templateDTO.getNumber(),templateDTO.getFirst()) <= 0){ + if (Double.compare(templateDTO.getNumber(), templateDTO.getFirst()) <= 0) { storePostage = NumberUtil.round(NumberUtil.add(storePostage, - templateDTO.getFirstPrice()),2); - }else{ + templateDTO.getFirstPrice()), 2); + } else { BigDecimal fristPrice = NumberUtil.add(storePostage, templateDTO.getFirstPrice()); - if(templateDTO.get_continue() <= 0){ + if (templateDTO.get_continue() <= 0) { storePostage = fristPrice; - }else{ + } else { //续件平均值且向上取整数 double average = Math.ceil(NumberUtil.div(NumberUtil.sub(templateDTO.getNumber(), templateDTO.getFirst()), templateDTO.get_continue().doubleValue())); //最终邮费 - storePostage = NumberUtil.add(fristPrice,NumberUtil.mul(average, + storePostage = NumberUtil.add(fristPrice, NumberUtil.mul(average, templateDTO.getContinuePrice())); } } isFirst = false; - }else{ + } else { //多件直接在以前的基数继续续建 - if(templateDTO.get_continue() > 0){ + if (templateDTO.get_continue() > 0) { //续件平均值且向上取整数 double average = Math.ceil( NumberUtil.div( @@ -2118,7 +2107,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl cartInfo, String key) { BigDecimal sumPrice = BigDecimal.ZERO; - if("truePrice".equals(key)){ + if ("truePrice".equals(key)) { for (YxStoreCartQueryVo storeCart : cartInfo) { - sumPrice = NumberUtil.add(sumPrice,NumberUtil.mul(storeCart.getCartNum(),storeCart.getTruePrice())); + sumPrice = NumberUtil.add(sumPrice, NumberUtil.mul(storeCart.getCartNum(), storeCart.getTruePrice())); } - }else if("costPrice".equals(key)){ + } else if ("costPrice".equals(key)) { for (YxStoreCartQueryVo storeCart : cartInfo) { sumPrice = NumberUtil.add(sumPrice, - NumberUtil.mul(storeCart.getCartNum(),storeCart.getCostPrice())); + NumberUtil.mul(storeCart.getCartNum(), storeCart.getCostPrice())); } - }else if("vipTruePrice".equals(key)){ + } else if ("vipTruePrice".equals(key)) { for (YxStoreCartQueryVo storeCart : cartInfo) { sumPrice = NumberUtil.add(sumPrice, - NumberUtil.mul(storeCart.getCartNum(),storeCart.getVipTruePrice())); + NumberUtil.mul(storeCart.getCartNum(), storeCart.getVipTruePrice())); } - }else if("payIntegral".equals(key)){ + } else if ("payIntegral".equals(key)) { for (YxStoreCartQueryVo storeCart : cartInfo) { - if(storeCart.getProductInfo().getAttrInfo() != null && storeCart.getProductInfo().getAttrInfo().getIntegral() != null){ + if (storeCart.getProductInfo().getAttrInfo() != null && storeCart.getProductInfo().getAttrInfo().getIntegral() != null) { sumPrice = NumberUtil.add(sumPrice, NumberUtil.mul(storeCart.getCartNum(), storeCart.getProductInfo().getAttrInfo().getIntegral())); } @@ -2171,18 +2161,19 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl nameList = storeCartService.findCateName(); - Map childrenMap = new HashMap<>(); - nameList.forEach(i ->{ - if(i != null) { - if(childrenMap.containsKey(i.getCatename())) { - childrenMap.put(i.getCatename(), childrenMap.get(i.getCatename())+1); - }else { + List nameList = storeCartService.findCateName(); + Map childrenMap = new HashMap<>(); + nameList.forEach(i -> { + if (i != null) { + if (childrenMap.containsKey(i.getCatename())) { + childrenMap.put(i.getCatename(), childrenMap.get(i.getCatename()) + 1); + } else { childrenMap.put(i.getCatename(), 1); } } @@ -2190,7 +2181,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl list = new ArrayList<>(); List columns = new ArrayList<>(); - childrenMap.forEach((k,v) ->{ + childrenMap.forEach((k, v) -> { OrderCountDto.OrderCountData orderCountData = new OrderCountDto.OrderCountData(); orderCountData.setName(k); orderCountData.setValue(v); @@ -2205,6 +2196,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl chartCount() { Map map = new LinkedHashMap<>(); - Date nowMonth =DateUtil.beginOfMonth(new Date()); + Date nowMonth = DateUtil.beginOfMonth(new Date()); - map.put("chart",yxStoreOrderMapper.chartList(nowMonth)); - map.put("chartT",yxStoreOrderMapper.chartListT(nowMonth)); + map.put("chart", yxStoreOrderMapper.chartList(nowMonth)); + map.put("chartT", yxStoreOrderMapper.chartListT(nowMonth)); return map; } @Override public void retrunStock(String orderId) { - YxStoreOrderQueryVo order = this.getOrderInfo(orderId,null); - this.regressionIntegral(order,1); - this.regressionStock(order,1); - this.regressionCoupon(order,1); + YxStoreOrderQueryVo order = this.getOrderInfo(orderId, null); + this.regressionIntegral(order, 1); + this.regressionStock(order, 1); + this.regressionCoupon(order, 1); } @Override @@ -2263,22 +2256,20 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl queryAll(YxStoreOrderQueryCriteria criteria){ + public List queryAll(YxStoreOrderQueryCriteria criteria) { return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreOrder.class, criteria)); } - @Override @Transactional(rollbackFor = Exception.class) public void update(YxStoreOrder resources) { YxStoreOrder yxStoreOrder = this.getById(resources.getId()); YxStoreOrder yxStoreOrder1 = this.getOne(new LambdaQueryWrapper() - .eq(YxStoreOrder::getUnique,resources.getUnique())); - if(yxStoreOrder1 != null && !yxStoreOrder1.getId().equals(yxStoreOrder.getId())){ - throw new EntityExistException(YxStoreOrder.class,"unique",resources.getUnique()); + .eq(YxStoreOrder::getUnique, resources.getUnique())); + if (yxStoreOrder1 != null && !yxStoreOrder1.getId().equals(yxStoreOrder.getId())) { + throw new EntityExistException(YxStoreOrder.class, "unique", resources.getUnique()); } yxStoreOrder.copy(resources); this.saveOrUpdate(yxStoreOrder); @@ -2289,7 +2280,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl all, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); for (YxStoreOrderDto yxStoreOrder : all) { - Map map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); map.put("订单号", yxStoreOrder.getOrderId()); map.put("用户id", yxStoreOrder.getUid()); map.put("用户姓名", yxStoreOrder.getRealName()); @@ -2327,7 +2318,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl 0) { + if (yxStoreOrder.getStoreId() > 0) { String storeName = systemStoreService.getById(yxStoreOrder.getStoreId()).getName(); yxStoreOrderDto.setStoreName(storeName); } //订单状态 String orderStatusStr = OrderUtil.orderStatusStr(yxStoreOrder.getPaid() - ,yxStoreOrder.getStatus(),yxStoreOrder.getShippingType() - ,yxStoreOrder.getRefundStatus()); + , yxStoreOrder.getStatus(), yxStoreOrder.getShippingType() + , yxStoreOrder.getRefundStatus()); - if(_status == 3){ + if (_status == 3) { String refundTime = DateUtil.formatDateTime(yxStoreOrder.getRefundReasonTime()); - String str = "申请退款"+ - "退款原因:"+yxStoreOrder.getRefundReasonWap()+"" + - "备注说明:"+yxStoreOrder.getRefundReasonWapExplain()+"" + - "退款时间:"+refundTime+""; + String str = "申请退款" + + "退款原因:" + yxStoreOrder.getRefundReasonWap() + "" + + "备注说明:" + yxStoreOrder.getRefundReasonWapExplain() + "" + + "退款时间:" + refundTime + ""; orderStatusStr = str; } yxStoreOrderDto.setStatusName(orderStatusStr); @@ -2381,22 +2374,22 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl storeOrderStatuses = orderStatusService.list(new LambdaQueryWrapper() - .eq(YxStoreOrderStatus::getOid,yxStoreOrder.getId())); + .eq(YxStoreOrderStatus::getOid, yxStoreOrder.getId())); List orderStatusDtos = generator.convert(storeOrderStatuses, YxStoreOrderStatusDto.class); yxStoreOrderDto.setStoreOrderStatusList(orderStatusDtos); //添加购物车详情 List cartInfos = storeOrderCartInfoService.list( - new LambdaQueryWrapper().eq(YxStoreOrderCartInfo::getOid,yxStoreOrder.getId())); + new LambdaQueryWrapper().eq(YxStoreOrderCartInfo::getOid, yxStoreOrder.getId())); List cartInfoDTOS = new ArrayList<>(); for (YxStoreOrderCartInfo cartInfo : cartInfos) { StoreOrderCartInfoDto cartInfoDTO = new StoreOrderCartInfoDto(); @@ -2407,7 +2400,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl queryAll(List ids) { - List yxStoreOrders = this.list(new LambdaQueryWrapper().in(YxStoreOrder::getOrderId,ids)); + List yxStoreOrders = this.list(new LambdaQueryWrapper().in(YxStoreOrder::getOrderId, ids)); List storeOrderDTOS = new ArrayList<>(); - for (YxStoreOrder yxStoreOrder :yxStoreOrders) { + for (YxStoreOrder yxStoreOrder : yxStoreOrders) { this.orderList(storeOrderDTOS, yxStoreOrder); } - Map map = new LinkedHashMap<>(2); - map.put("content",storeOrderDTOS); + Map map = new LinkedHashMap<>(2); + map.put("content", storeOrderDTOS); return map; } @@ -2430,31 +2423,32 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl storeOrderDTOS, YxStoreOrder yxStoreOrder) { YxStoreOrderDto yxStoreOrderDto = generator.convert(yxStoreOrder, YxStoreOrderDto.class); - Integer _status = OrderUtil.orderStatus(yxStoreOrder.getPaid(),yxStoreOrder.getStatus(), + Integer _status = OrderUtil.orderStatus(yxStoreOrder.getPaid(), yxStoreOrder.getStatus(), yxStoreOrder.getRefundStatus()); - if(yxStoreOrder.getStoreId() > 0) { + if (yxStoreOrder.getStoreId() > 0) { String storeName = systemStoreService.getById(yxStoreOrder.getStoreId()).getName(); yxStoreOrderDto.setStoreName(storeName); } //订单状态 String orderStatusStr = OrderUtil.orderStatusStr(yxStoreOrder.getPaid() - ,yxStoreOrder.getStatus(),yxStoreOrder.getShippingType() - ,yxStoreOrder.getRefundStatus()); + , yxStoreOrder.getStatus(), yxStoreOrder.getShippingType() + , yxStoreOrder.getRefundStatus()); - if(_status == 3){ + if (_status == 3) { String refundTime = DateUtil.formatDateTime(yxStoreOrder.getRefundReasonTime()); - String str = "申请退款
"+ - "退款原因:"+yxStoreOrder.getRefundReasonWap()+"
" + - "备注说明:"+yxStoreOrder.getRefundReasonWapExplain()+"
" + - "退款时间:"+refundTime+"
"; + String str = "申请退款
" + + "退款原因:" + yxStoreOrder.getRefundReasonWap() + "
" + + "备注说明:" + yxStoreOrder.getRefundReasonWapExplain() + "
" + + "退款时间:" + refundTime + "
"; orderStatusStr = str; } yxStoreOrderDto.setStatusName(orderStatusStr); @@ -2462,16 +2456,16 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl cartInfos = storeOrderCartInfoService.list( - new LambdaQueryWrapper().eq(YxStoreOrderCartInfo::getOid,yxStoreOrder.getId())); + new LambdaQueryWrapper().eq(YxStoreOrderCartInfo::getOid, yxStoreOrder.getId())); List cartInfoDTOS = new ArrayList<>(); for (YxStoreOrderCartInfo cartInfo : cartInfos) { StoreOrderCartInfoDto cartInfoDTO = new StoreOrderCartInfoDto(); @@ -2481,61 +2475,59 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl 0 || combinationId > 0){ + if (pinkId > 0 || combinationId > 0) { YxStorePink storePink = storePinkService.getOne(new LambdaQueryWrapper() - .eq(YxStorePink::getOrderIdKey,id)); - if(ObjectUtil.isNull(storePink)) { + .eq(YxStorePink::getOrderIdKey, id)); + if (ObjectUtil.isNull(storePink)) { str = "[拼团订单]"; - }else{ - if(OrderInfoEnum.PINK_STATUS_1.getValue().equals(storePink.getStatus())){ + } else { + if (OrderInfoEnum.PINK_STATUS_1.getValue().equals(storePink.getStatus())) { str = "[拼团订单]正在进行中"; - }else if(OrderInfoEnum.PINK_STATUS_2.getValue().equals(storePink.getStatus())){ + } else if (OrderInfoEnum.PINK_STATUS_2.getValue().equals(storePink.getStatus())) { str = "[拼团订单]已完成"; - } else if(OrderInfoEnum.PINK_STATUS_3.getValue().equals(storePink.getStatus())){ + } else if (OrderInfoEnum.PINK_STATUS_3.getValue().equals(storePink.getStatus())) { str = "[拼团订单]未完成"; - }else{ + } else { str = "[拼团订单]历史订单"; } } - }else if(seckillId > 0){ + } else if (seckillId > 0) { str = "[秒杀订单]"; - }else if(bargainId > 0){ + } else if (bargainId > 0) { str = "[砍价订单]"; } - if(OrderInfoEnum.SHIPPIING_TYPE_2.getValue().equals(shippingType)) { + if (OrderInfoEnum.SHIPPIING_TYPE_2.getValue().equals(shippingType)) { str = "[核销订单]"; } - if(payIntegral.compareTo(new BigDecimal("0.00")) == 1) { + if (payIntegral.compareTo(new BigDecimal("0.00")) == 1) { str = "[积分兑换]"; } return str; } - } diff --git a/yshop-mall/src/main/java/co/yixiang/modules/product/service/YxStoreProductRelationService.java b/yshop-mall/src/main/java/co/yixiang/modules/product/service/YxStoreProductRelationService.java index b23c9815..90cc825e 100644 --- a/yshop-mall/src/main/java/co/yixiang/modules/product/service/YxStoreProductRelationService.java +++ b/yshop-mall/src/main/java/co/yixiang/modules/product/service/YxStoreProductRelationService.java @@ -85,4 +85,9 @@ public interface YxStoreProductRelationService extends BaseService all, HttpServletResponse response) throws IOException; + /** + * 批量删除 + * @param ids / + */ + void collectDelFoot(List ids); } diff --git a/yshop-mall/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductRelationServiceImpl.java b/yshop-mall/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductRelationServiceImpl.java index deae2814..709c3fbe 100644 --- a/yshop-mall/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductRelationServiceImpl.java +++ b/yshop-mall/src/main/java/co/yixiang/modules/product/service/impl/YxStoreProductRelationServiceImpl.java @@ -166,4 +166,9 @@ public class YxStoreProductRelationServiceImpl extends BaseServiceImpl ids) { + yxStoreProductRelationMapper.deleteBatchIds(ids); + } } diff --git a/yshop-mall/src/main/java/co/yixiang/modules/product/service/mapper/YxStoreProductRelationMapper.java b/yshop-mall/src/main/java/co/yixiang/modules/product/service/mapper/YxStoreProductRelationMapper.java index cd912947..305f48fd 100644 --- a/yshop-mall/src/main/java/co/yixiang/modules/product/service/mapper/YxStoreProductRelationMapper.java +++ b/yshop-mall/src/main/java/co/yixiang/modules/product/service/mapper/YxStoreProductRelationMapper.java @@ -30,7 +30,7 @@ import java.util.List; @Repository public interface YxStoreProductRelationMapper extends CoreMapper { - @Select("select B.id pid,A.type as category,B.store_name as storeName,B.price,B.is_integral as isIntegral," + + @Select("select B.id pid,A.type as category,B.store_name as storeName,B.price,B.is_integral as isIntegral,A.id id," + "B.ot_price as otPrice,B.sales,B.image,B.is_show as isShow" + " from yx_store_product_relation A left join yx_store_product B " + "on A.product_id = B.id where A.type=#{type} and A.uid=#{uid} and A.is_del = 0 and B.is_del = 0 order by A.create_time desc") diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSales.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSales.java new file mode 100644 index 00000000..d1cf43cf --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSales.java @@ -0,0 +1,79 @@ +package co.yixiang.modules.sales.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.sql.Timestamp; + +/** + * @author : gzlv 2021/6/27 15:42 + */ +@Data +@TableName("yx_store_after_sales") +public class StoreAfterSales { + + /** id */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** 订单号 */ + private String orderCode; + + /** 退款金额 */ + private BigDecimal refundAmount; + + /** 服务类型0仅退款1退货退款 */ + private Integer serviceType; + + /** 申请原因 */ + private String reasons; + + /** 说明 */ + private String explains; + + /** 说明图片->多个用逗号分割 */ + private String explainImg; + + @ApiModelProperty(value = "快递公司编码") + private String shipperCode; + + /** 物流单号 */ + private String deliverySn; + + /** 物流名称 */ + private String deliveryName; + + /** 状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3已完成 */ + private Integer state; + + /** 售后状态-0正常1用户取消2商家拒绝 */ + private Integer salesState; + + /** 添加时间 */ + private Timestamp createTime; + + /** 逻辑删除 */ + private Integer isDel; + + /** 用户id */ + private Long userId; + + /** + * 收货人 + */ + private String consignee; + + /** + * 手机号 + */ + private String phoneNumber; + + /** + * 地址 + */ + private String address; +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesItem.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesItem.java new file mode 100644 index 00000000..1102f24f --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesItem.java @@ -0,0 +1,30 @@ +package co.yixiang.modules.sales.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +/** + * @author : gzlv 2021/6/27 15:49 + */ +@Data +@TableName("yx_store_after_sales_item") +public class StoreAfterSalesItem { + + /** 主键id */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** 售后id */ + private Long storeAfterSalesId; + + /** 商品id */ + private Long productId; + + /** 退货东西的详情信息 */ + private String cartInfo; + + /** 逻辑删除 */ + private Integer isDel; +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesStatus.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesStatus.java new file mode 100644 index 00000000..74418cf6 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/domain/StoreAfterSalesStatus.java @@ -0,0 +1,35 @@ +package co.yixiang.modules.sales.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.sql.Timestamp; + +/** + * @author : gzlv 2021/6/27 15:51 + */ +@Data +@TableName("yx_store_after_sales_status") +public class StoreAfterSalesStatus { + + /** Id */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** 售后id */ + private Long storeAfterSalesId; + + /** 操作类型 0售后订单生成 1后台审核成功 2用户发货 3打款 4审核失败 5用户撤销*/ + private Integer changeType; + + /** 操作备注 */ + private String changeMessage; + + /** 操作时间 */ + private Timestamp changeTime; + + /** 操作人 */ + private String operator; +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/param/ProsuctParam.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/param/ProsuctParam.java new file mode 100644 index 00000000..f267fde3 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/param/ProsuctParam.java @@ -0,0 +1,16 @@ +package co.yixiang.modules.sales.param; + +import lombok.Data; + +/** + * @author : gzlv 2021/6/27 17:18 + */ +@Data +public class ProsuctParam { + + /** + * 商品id + */ + private Long productId; + +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/param/SalesCheckDto.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/param/SalesCheckDto.java new file mode 100644 index 00000000..973d8fcb --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/param/SalesCheckDto.java @@ -0,0 +1,40 @@ +package co.yixiang.modules.sales.param; + +import lombok.Data; + +/** + * @author : gzlv 2021/6/29 5:25 + */ +@Data +public class SalesCheckDto { + + /** + * 售后id + */ + private Long salesId; + + /** + * 订单编号 + */ + private String orderCode; + + /** + * 审核状态0成功1失败 + */ + private Integer approvalStatus; + + /** + * 收货人 + */ + private String consignee; + + /** + * 手机号 + */ + private String phoneNumber; + + /** + * 地址 + */ + private String address; +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/param/StoreAfterSalesParam.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/param/StoreAfterSalesParam.java new file mode 100644 index 00000000..6a046a65 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/param/StoreAfterSalesParam.java @@ -0,0 +1,48 @@ +package co.yixiang.modules.sales.param; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.List; + +/** + * @author : gzlv 2021/6/27 16:36 + */ +@Data +public class StoreAfterSalesParam { + + /** + * 订单号 + */ + @NotBlank + private String orderCode; + + /** + * 服务类型 0仅退款1退货退款 + */ + @NotBlank + private Integer serviceType; + + /** + * 申请原因 + */ + @NotBlank + private String reasonForApplication; + + /** + * 申请说明 + */ + private String applicationInstructions; + + /** + * 申请说明图片 + */ + private String applicationDescriptionPicture; + + /** + * 商品数据 + */ + @NotBlank + private List productParamList; + +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesDto.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesDto.java new file mode 100644 index 00000000..559f56cb --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesDto.java @@ -0,0 +1,75 @@ +/** +* Copyright (C) 2018-2021 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.sales.param; + +import lombok.Data; +import java.util.Date; +import java.math.BigDecimal; +import java.io.Serializable; + +/** +* @author gzlv +* @date 2021-06-30 +*/ +@Data +public class YxStoreAfterSalesDto implements Serializable { + + private Long id; + + /** 订单号 */ + private String orderCode; + + /** 退款金额 */ + private BigDecimal refundAmount; + + /** 服务类型0仅退款1退货退款 */ + private Integer serviceType; + + /** 申请原因 */ + private String reasons; + + /** 说明 */ + private String explains; + + /** 说明图片->多个用逗号分割 */ + private String explainImg; + + /** 物流公司编码 */ + private String shipperCode; + + /** 物流单号 */ + private String deliverySn; + + /** 物流名称 */ + private String deliveryName; + + /** 状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3退款成功 */ + private Integer state; + + /** 售后状态-0正常1用户取消2商家拒绝 */ + private Integer salesState; + + /** 添加时间 */ + private Date createTime; + + /** 逻辑删除 */ + private Integer isDel; + + /** 用户id */ + private Long userId; + + /** 商家收货人 */ + private String consignee; + + /** 商家手机号 */ + private String phoneNumber; + + /** 商家地址 */ + private String address; +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesQueryCriteria.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesQueryCriteria.java new file mode 100644 index 00000000..4e3b7282 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/param/YxStoreAfterSalesQueryCriteria.java @@ -0,0 +1,41 @@ +/** +* Copyright (C) 2018-2021 +* All rights reserved, Designed By www.yixiang.co +* 注意: +* 本软件为www.yixiang.co开发研制,未经购买不得使用 +* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台) +* 一经发现盗用、分享等行为,将追究法律责任,后果自负 +*/ +package co.yixiang.modules.sales.param; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.Date; +import java.util.List; +import co.yixiang.annotation.Query; + +/** +* @author gzlv +* @date 2021-06-30 +*/ +@Data +public class YxStoreAfterSalesQueryCriteria{ + + /** + * 订单号 + */ + private String orderCode; + + /** 售后状态-0正常1用户取消2商家拒绝 */ + private Integer salesState; + + private List time; + + /** 状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3已完成 */ + private Integer state; + + /** 服务类型0仅退款1退货退款 */ + private Integer serviceType; +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesItemService.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesItemService.java new file mode 100644 index 00000000..bd567799 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesItemService.java @@ -0,0 +1,10 @@ +package co.yixiang.modules.sales.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.sales.domain.StoreAfterSalesItem; + +/** + * @author : gzlv 2021/6/27 15:55 + */ +public interface StoreAfterSalesItemService extends BaseService { +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesService.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesService.java new file mode 100644 index 00000000..c229e48a --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesService.java @@ -0,0 +1,130 @@ +package co.yixiang.modules.sales.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.sales.domain.StoreAfterSales; +import co.yixiang.modules.sales.param.StoreAfterSalesParam; +import co.yixiang.modules.sales.param.YxStoreAfterSalesDto; +import co.yixiang.modules.sales.param.YxStoreAfterSalesQueryCriteria; +import co.yixiang.modules.sales.service.vo.StoreAfterSalesVo; +import co.yixiang.modules.sales.service.vo.YxStoreOrderCartInfoVo; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * @author : gzlv 2021/6/27 15:54 + */ +public interface StoreAfterSalesService extends BaseService { + + /** + * 创建售后订单 + * + * @param userId 用户id + * @param nickname 用户昵称 + * @param storeAfterSalesParam / + */ + void applyForAfterSales(Long userId, String nickname, StoreAfterSalesParam storeAfterSalesParam); + + /** + * 查询订单详情 + * @param key 订单号 + */ + List checkOrderDetails(String key); + + /** + * 查询列表 + * @param uid 用户id + * @param status 状态 + * @param page 页 + * @param orderCode + * @param limit 数量 + * @return + */ + Map salesList(Long uid, Integer status, Integer page, String orderCode, Integer limit); + + /** + * 查询详情 + * @param key 订单号 + * @param id + * @param uid 用户id + */ + List getStoreInfo(String key, Long id, Long uid); + + /** + * + * @param storeInfo + * @return + */ + StoreAfterSalesVo handleSales(StoreAfterSalesVo storeInfo); + + /** + * 撤销申请 + * @param key 订单号 + * @param uid 用户id + * @param aLong + * @return Boolean + */ + Boolean revoke(String key, Long uid, Long aLong); + + /** + * 添加快递信息 + * @param code 物流公司编码 + * @param name 物流公司名称 + * @param postalCode + * @param orderCode + * @return + */ + Boolean addLogisticsInformation(String code, String name, String postalCode ,String orderCode); + + /** + * 删除售后订单 + * @param orderCode / + * @param id + * @return / + */ + Boolean deleteAfterSalesOrder(String orderCode, Long id); + + /** + * 售后订单审核 + * @param salesId 售后id + * @param orderCode 订单id + * @param approvalStatus 审核状态 + * @param consignee 收货人 + * @param phoneNumber 收货人电话 + * @param address 地址 + * @return / + */ + Object salesCheck(Long salesId, String orderCode, Integer approvalStatus, String consignee, String phoneNumber, String address); + + /** + * 打款 + */ + StoreAfterSales makeMoney(Long salesId, String orderCode); + + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(YxStoreAfterSalesQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(YxStoreAfterSalesQueryCriteria criteria); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesStatusService.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesStatusService.java new file mode 100644 index 00000000..3232e20a --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/StoreAfterSalesStatusService.java @@ -0,0 +1,10 @@ +package co.yixiang.modules.sales.service; + +import co.yixiang.common.service.BaseService; +import co.yixiang.modules.sales.domain.StoreAfterSalesStatus; + +/** + * @author : gzlv 2021/6/27 15:55 + */ +public interface StoreAfterSalesStatusService extends BaseService { +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesItemServiceImpl.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesItemServiceImpl.java new file mode 100644 index 00000000..049759c3 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesItemServiceImpl.java @@ -0,0 +1,19 @@ +package co.yixiang.modules.sales.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.modules.sales.domain.StoreAfterSalesItem; +import co.yixiang.modules.sales.service.StoreAfterSalesItemService; +import co.yixiang.modules.sales.service.mapper.StoreAfterSalesItemMapper; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author : gzlv 2021/6/27 15:55 + */ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class StoreAfterSalesItemServiceImpl extends BaseServiceImpl implements StoreAfterSalesItemService { +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesServiceImpl.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesServiceImpl.java new file mode 100644 index 00000000..89b7e498 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesServiceImpl.java @@ -0,0 +1,414 @@ +package co.yixiang.modules.sales.service.impl; + +import cn.hutool.core.util.NumberUtil; +import co.yixiang.api.YshopException; +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.common.utils.QueryHelpPlus; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.enums.OrderInfoEnum; +import co.yixiang.enums.ShopCommonEnum; +import co.yixiang.exception.ErrorRequestException; +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import co.yixiang.modules.order.domain.YxStoreOrder; +import co.yixiang.modules.order.domain.YxStoreOrderCartInfo; +import co.yixiang.modules.order.service.mapper.StoreOrderCartInfoMapper; +import co.yixiang.modules.order.service.mapper.StoreOrderMapper; +import co.yixiang.modules.sales.domain.StoreAfterSales; +import co.yixiang.modules.sales.domain.StoreAfterSalesItem; +import co.yixiang.modules.sales.domain.StoreAfterSalesStatus; +import co.yixiang.modules.sales.param.ProsuctParam; +import co.yixiang.modules.sales.param.StoreAfterSalesParam; +import co.yixiang.modules.sales.param.YxStoreAfterSalesDto; +import co.yixiang.modules.sales.param.YxStoreAfterSalesQueryCriteria; +import co.yixiang.modules.sales.service.StoreAfterSalesService; +import co.yixiang.modules.sales.service.mapper.StoreAfterSalesItemMapper; +import co.yixiang.modules.sales.service.mapper.StoreAfterSalesMapper; +import co.yixiang.modules.sales.service.mapper.StoreAfterSalesStatusMapper; +import co.yixiang.modules.sales.service.vo.StoreAfterSalesVo; +import co.yixiang.modules.sales.service.vo.YxStoreOrderCartInfoVo; +import co.yixiang.utils.FileUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.AllArgsConstructor; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author : gzlv 2021/6/27 15:56 + */ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class StoreAfterSalesServiceImpl extends BaseServiceImpl implements StoreAfterSalesService { + + private final StoreOrderMapper storeOrderMapper; + private final StoreOrderCartInfoMapper storeOrderCartInfoMapper; + private final StoreAfterSalesItemMapper storeAfterSalesItemMapper; + private final StoreAfterSalesStatusMapper storeAfterSalesStatusMapper; + private final IGenerator generator; + + @Override + public void applyForAfterSales(Long userId, String nickname, StoreAfterSalesParam storeAfterSalesParam) { + + YxStoreOrder yxStoreOrder = storeOrderMapper.selectOne(Wrappers.lambdaQuery().eq(YxStoreOrder::getOrderId, storeAfterSalesParam.getOrderCode()).eq(YxStoreOrder::getUid, userId)); + checkOrder(yxStoreOrder); + //商品除去优惠后的总价格 + BigDecimal totalPrice = BigDecimal.ZERO; + //拿到所有的商品 + List yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.lambdaQuery().eq(YxStoreOrderCartInfo::getOid, yxStoreOrder.getId())); + for (YxStoreOrderCartInfo yxStoreOrderCartInfo : yxStoreOrderCartInfos) { + YxStoreCartQueryVo cartInfo = JSONObject.parseObject(yxStoreOrderCartInfo.getCartInfo(), YxStoreCartQueryVo.class); + ProsuctParam prosuctParam = storeAfterSalesParam.getProductParamList().stream().filter(item -> item.getProductId().equals(yxStoreOrderCartInfo.getProductId())).findFirst().orElse(new ProsuctParam()); + if (prosuctParam.getProductId() != null) { + //商品优惠前总金额 + BigDecimal totalAmountOfGoods = NumberUtil.mul(cartInfo.getTruePrice(), cartInfo.getCartNum()); + //商品优惠总金额 + BigDecimal commodityDiscountAmount = NumberUtil.mul(NumberUtil.div(totalAmountOfGoods, NumberUtil.sub(yxStoreOrder.getTotalPrice(), yxStoreOrder.getPayPostage())), yxStoreOrder.getCouponPrice()); + //商品优惠后总金额 + totalPrice = NumberUtil.add(totalPrice, NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount)); + + yxStoreOrderCartInfo.setIsAfterSales(0); + storeOrderCartInfoMapper.updateById(yxStoreOrderCartInfo); + + yxStoreOrder.setStatus(-1); + storeOrderMapper.updateById(yxStoreOrder); + } + } + //生成售后订单 + StoreAfterSales storeAfterSales = new StoreAfterSales(); + storeAfterSales.setOrderCode(storeAfterSalesParam.getOrderCode()); + storeAfterSales.setRefundAmount(totalPrice); + storeAfterSales.setServiceType(storeAfterSalesParam.getServiceType()); + storeAfterSales.setReasons(storeAfterSalesParam.getReasonForApplication()); + storeAfterSales.setExplains(storeAfterSalesParam.getApplicationInstructions()); + storeAfterSales.setExplainImg(storeAfterSalesParam.getApplicationDescriptionPicture()); + storeAfterSales.setState(0); + storeAfterSales.setSalesState(0); + storeAfterSales.setCreateTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSales.setIsDel(0); + storeAfterSales.setUserId(userId); + baseMapper.insert(storeAfterSales); + //售后商品详情 + for (ProsuctParam prosuctParam : storeAfterSalesParam.getProductParamList()) { + YxStoreOrderCartInfo yxStoreOrderCartInfo = yxStoreOrderCartInfos.stream().filter(item -> item.getProductId().equals(prosuctParam.getProductId())).findFirst().orElse(new YxStoreOrderCartInfo()); + StoreAfterSalesItem storeAfterSalesItem = new StoreAfterSalesItem(); + storeAfterSalesItem.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesItem.setProductId(yxStoreOrderCartInfo.getProductId()); + storeAfterSalesItem.setCartInfo(yxStoreOrderCartInfo.getCartInfo()); + storeAfterSalesItem.setIsDel(0); + storeAfterSalesItemMapper.insert(storeAfterSalesItem); + } + + //操作记录 + StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus(); + storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesStatus.setChangeType(0); + storeAfterSalesStatus.setChangeMessage("售后订单生成"); + storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSalesStatus.setOperator(nickname); + storeAfterSalesStatusMapper.insert(storeAfterSalesStatus); + + } + + @Override + public List checkOrderDetails(String key) { + List yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.lambdaQuery().eq(YxStoreOrderCartInfo::getOid, key)); + YxStoreOrder yxStoreOrder = storeOrderMapper.selectById(key); + List yxStoreOrderCartInfoVos = new ArrayList<>(); + for (YxStoreOrderCartInfo yxStoreOrderCartInfo : yxStoreOrderCartInfos) { + + YxStoreOrderCartInfoVo yxStoreOrderCartInfoVo = new YxStoreOrderCartInfoVo(); + yxStoreOrderCartInfoVo.setId(yxStoreOrderCartInfo.getId()); + yxStoreOrderCartInfoVo.setOid(yxStoreOrderCartInfo.getOid()); + yxStoreOrderCartInfoVo.setCartId(yxStoreOrderCartInfo.getCartId()); + yxStoreOrderCartInfoVo.setProductId(yxStoreOrderCartInfo.getProductId()); + YxStoreCartQueryVo cartInfo = JSONObject.parseObject(yxStoreOrderCartInfo.getCartInfo(), YxStoreCartQueryVo.class); + yxStoreOrderCartInfoVo.setCartInfo(cartInfo); + yxStoreOrderCartInfoVo.setUnique(yxStoreOrderCartInfo.getUnique()); + yxStoreOrderCartInfoVo.setIsAfterSales(yxStoreOrderCartInfo.getIsAfterSales() == null ? 0 : yxStoreOrderCartInfo.getIsAfterSales()); + + //商品优惠前总金额 + BigDecimal totalAmountOfGoods = NumberUtil.mul(cartInfo.getTruePrice(), cartInfo.getCartNum()); + //商品优惠总金额 + BigDecimal commodityDiscountAmount = NumberUtil.mul(NumberUtil.div(totalAmountOfGoods, NumberUtil.sub(yxStoreOrder.getTotalPrice(), yxStoreOrder.getPayPostage())), yxStoreOrder.getCouponPrice()); + + yxStoreOrderCartInfoVo.setRefundablePrice(NumberUtil.sub(totalAmountOfGoods, commodityDiscountAmount)); + yxStoreOrderCartInfoVos.add(yxStoreOrderCartInfoVo); + } + + return yxStoreOrderCartInfoVos; + + } + + @Override + public Map salesList(Long uid, Integer status, Integer page, String orderCode, Integer limit) { + Page storeAfterSalesPage = new Page<>(page, limit); + List integers = new ArrayList<>(); + if (status == 1) { + integers.add(0); + integers.add(1); + integers.add(2); + } + if (status == 2) { + integers.add(3); + } + baseMapper.selectPage(storeAfterSalesPage, Wrappers.lambdaQuery() + .eq(uid != null, StoreAfterSales::getUserId, uid).in(status == 1, StoreAfterSales::getState, integers) + .in(status == 2, StoreAfterSales::getState, integers) + .eq(StringUtils.isNotBlank(orderCode), StoreAfterSales::getOrderCode, orderCode) + .orderByDesc(StoreAfterSales::getCreateTime) + .eq(StoreAfterSales::getIsDel, ShopCommonEnum.DELETE_0.getValue())); + List storeAfterSalesVos = generator.convert(storeAfterSalesPage.getRecords(), StoreAfterSalesVo.class); + Map map = new HashMap<>(); + if (uid == null) { + map.put("content", storeAfterSalesVos.stream().map(this::handleSales).collect(Collectors.toList())); + map.put("totalElements", storeAfterSalesPage.getTotal()); + } else { + map.put("list", storeAfterSalesVos.stream().map(this::handleSales).collect(Collectors.toList())); + map.put("total", storeAfterSalesPage.getTotal()); + map.put("totalPage", storeAfterSalesPage.getPages()); + } + return map; + } + + @Override + public List getStoreInfo(String key, Long id, Long uid) { + List storeAfterSales = baseMapper.selectList(Wrappers.lambdaQuery().eq(id != null, StoreAfterSales::getId, id).eq(StoreAfterSales::getUserId, uid).eq(StoreAfterSales::getOrderCode, key)); + return generator.convert(storeAfterSales, StoreAfterSalesVo.class); + } + + /** + * 处理售后订单返回的状态 + * + * @param storeAfterSalesVo / + * @return StoreAfterSalesVo / + */ + @Override + public StoreAfterSalesVo handleSales(StoreAfterSalesVo storeAfterSalesVo) { + List storeAfterSalesItems = storeAfterSalesItemMapper.selectList(Wrappers.lambdaQuery().eq(StoreAfterSalesItem::getStoreAfterSalesId, storeAfterSalesVo.getId())); + List cartInfo = storeAfterSalesItems.stream() + .map(cart -> JSON.parseObject(cart.getCartInfo(), YxStoreCartQueryVo.class)) + .collect(Collectors.toList()); + storeAfterSalesVo.setCartInfo(cartInfo); + List storeAfterSalesStatuses = storeAfterSalesStatusMapper.selectList(Wrappers.lambdaQuery().eq(StoreAfterSalesStatus::getStoreAfterSalesId, storeAfterSalesVo.getId())); + + storeAfterSalesVo.setCompleteTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 3).findFirst().orElse(new StoreAfterSalesStatus()).getChangeTime()); + storeAfterSalesVo.setDeliveryTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 2).findFirst().orElse(new StoreAfterSalesStatus()).getChangeTime()); + storeAfterSalesVo.setAuditFailedTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 4).findFirst().orElse(new StoreAfterSalesStatus()).getChangeTime()); + storeAfterSalesVo.setReviewTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 1).findFirst().orElse(new StoreAfterSalesStatus()).getChangeTime()); + storeAfterSalesVo.setRevocationTime(storeAfterSalesStatuses.stream().filter(item -> item.getChangeType() == 5).findFirst().orElse(new StoreAfterSalesStatus()).getChangeTime()); + return storeAfterSalesVo; + } + + @Override + public Boolean revoke(String key, Long uid, Long id) { + StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.lambdaQuery().eq(StoreAfterSales::getUserId, uid).eq(StoreAfterSales::getId, id).eq(StoreAfterSales::getOrderCode, key)); + if (storeAfterSales == null) { + throw new YshopException("未查询到售后订单信息"); + } + if (storeAfterSales.getState() == 2 || storeAfterSales.getState() == 3) { + throw new YshopException("订单不能撤销"); + } + storeAfterSales.setSalesState(1); + + YxStoreOrder yxStoreOrder = storeOrderMapper.selectOne(Wrappers.lambdaQuery().eq(YxStoreOrder::getOrderId, key)); + yxStoreOrder.setStatus(-2); + storeOrderMapper.updateById(yxStoreOrder); + + List yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.lambdaQuery().eq(YxStoreOrderCartInfo::getOid, yxStoreOrder.getId())); + for (YxStoreOrderCartInfo yxStoreOrderCartInfo : yxStoreOrderCartInfos) { + yxStoreOrderCartInfo.setIsAfterSales(1); + storeOrderCartInfoMapper.updateById(yxStoreOrderCartInfo); + } + + //操作记录 + StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus(); + storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesStatus.setChangeType(5); + storeAfterSalesStatus.setChangeMessage("售后订单生成"); + storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSalesStatus.setOperator("用户操作"); + storeAfterSalesStatusMapper.insert(storeAfterSalesStatus); + + return baseMapper.updateById(storeAfterSales) > 0; + } + + @Override + public Boolean addLogisticsInformation(String code, String name, String postalCode, String orderCode) { + StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.lambdaQuery().eq(StoreAfterSales::getOrderCode, orderCode)); + if (storeAfterSales.getState() != 1) { + throw new YshopException("当前状态不能添加物流信息!"); + } + storeAfterSales.setShipperCode(code); + storeAfterSales.setDeliverySn(postalCode); + storeAfterSales.setDeliveryName(name); + storeAfterSales.setState(2); + + //操作记录 + StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus(); + storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesStatus.setChangeType(2); + storeAfterSalesStatus.setChangeMessage("售后订单生成"); + storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSalesStatus.setOperator("用户操作"); + storeAfterSalesStatusMapper.insert(storeAfterSalesStatus); + + return baseMapper.updateById(storeAfterSales) > 0; + } + + @Override + public Boolean deleteAfterSalesOrder(String orderCode, Long id) { + StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.lambdaQuery().eq(StoreAfterSales::getId, id).eq(StoreAfterSales::getOrderCode, orderCode)); + return baseMapper.deleteById(storeAfterSales.getId()) > 0; + } + + @Override + public Object salesCheck(Long salesId, String orderCode, Integer approvalStatus, String consignee, String phoneNumber, String address) { + StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.lambdaQuery().eq(StoreAfterSales::getOrderCode, orderCode).eq(StoreAfterSales::getId, salesId)); + if (approvalStatus == 0) { + storeAfterSales.setState(1); + if (storeAfterSales.getServiceType() == 1) { + if (StringUtils.isEmpty(consignee) || StringUtils.isEmpty(phoneNumber) || StringUtils.isEmpty(address)) { + throw new ErrorRequestException("请输入收货人信息"); + } + storeAfterSales.setConsignee(consignee); + storeAfterSales.setPhoneNumber(phoneNumber); + storeAfterSales.setAddress(address); + } + //操作记录 + StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus(); + storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesStatus.setChangeType(1); + storeAfterSalesStatus.setChangeMessage("平台审核成功"); + storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSalesStatus.setOperator("admin"); + storeAfterSalesStatusMapper.insert(storeAfterSalesStatus); + } else { + storeAfterSales.setState(1); + storeAfterSales.setSalesState(2); + //操作记录 + StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus(); + storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesStatus.setChangeType(4); + storeAfterSalesStatus.setChangeMessage("平台审核失败"); + storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSalesStatus.setOperator("admin"); + storeAfterSalesStatusMapper.insert(storeAfterSalesStatus); + + this.makeMoney(storeAfterSales.getId(),storeAfterSales.getOrderCode()); + } + return baseMapper.updateById(storeAfterSales) > 0; + } + + @Override + public StoreAfterSales makeMoney(Long salesId, String orderCode) { + StoreAfterSales storeAfterSales = baseMapper.selectOne(Wrappers.lambdaQuery().eq(StoreAfterSales::getOrderCode, orderCode).eq(StoreAfterSales::getId, salesId)); + storeAfterSales.setState(3); + baseMapper.updateById(storeAfterSales); + //操作记录 + StoreAfterSalesStatus storeAfterSalesStatus = new StoreAfterSalesStatus(); + storeAfterSalesStatus.setStoreAfterSalesId(storeAfterSales.getId()); + storeAfterSalesStatus.setChangeType(3); + storeAfterSalesStatus.setChangeMessage("平台打款成功"); + storeAfterSalesStatus.setChangeTime(Timestamp.valueOf(LocalDateTime.now())); + storeAfterSalesStatus.setOperator("admin"); + storeAfterSalesStatusMapper.insert(storeAfterSalesStatus); + + YxStoreOrder yxStoreOrder = storeOrderMapper.selectOne(Wrappers.lambdaQuery().eq(YxStoreOrder::getOrderId, storeAfterSales.getOrderCode())); + yxStoreOrder.setStatus(-2); + storeOrderMapper.updateById(yxStoreOrder); + return storeAfterSales; + } + + /** + * 检查订单是否符合售后订单 + * + * @param yxStoreOrder 订单 + */ + private void checkOrder(YxStoreOrder yxStoreOrder) { + if (yxStoreOrder == null) { + throw new YshopException("未查询到订单信息"); + } + + if (!yxStoreOrder.getPaid().equals(OrderInfoEnum.PAY_STATUS_1.getValue()) || !yxStoreOrder.getRefundStatus().equals(OrderInfoEnum.REFUND_STATUS_0.getValue()) || !yxStoreOrder.getStatus().equals(OrderInfoEnum.STATUS_2.getValue())) { + throw new YshopException("订单状态不能售后"); + } + } + + @Override + //@Cacheable + public Map queryAll(YxStoreAfterSalesQueryCriteria criteria, Pageable pageable) { + Page storeAfterSalesPage = new Page<>(pageable.getPageNumber(), pageable.getPageSize()); + + LambdaQueryWrapper eq = Wrappers.lambdaQuery() + .in(ObjectUtils.isNotEmpty(criteria.getState()), StoreAfterSales::getState, criteria.getState()) + .eq(StringUtils.isNotBlank(criteria.getOrderCode()), StoreAfterSales::getOrderCode, criteria.getOrderCode()) + .eq(ObjectUtils.isNotEmpty(criteria.getSalesState()), StoreAfterSales::getSalesState, criteria.getSalesState()) + .eq(ObjectUtils.isNotEmpty(criteria.getServiceType()), StoreAfterSales::getServiceType, criteria.getServiceType()) + .orderByDesc(StoreAfterSales::getCreateTime) + .eq(StoreAfterSales::getIsDel, ShopCommonEnum.DELETE_0.getValue()); + if (CollectionUtils.isNotEmpty(criteria.getTime())) { + eq.ge(StoreAfterSales::getCreateTime, criteria.getTime().get(0)) + .le(StoreAfterSales::getCreateTime, criteria.getTime().get(1)); + } + + baseMapper.selectPage(storeAfterSalesPage, eq); + List storeAfterSalesVos = generator.convert(storeAfterSalesPage.getRecords(), StoreAfterSalesVo.class); + Map map = new HashMap<>(); + map.put("content", storeAfterSalesVos.stream().map(this::handleSales).collect(Collectors.toList())); + map.put("totalElements", storeAfterSalesPage.getTotal()); + return map; + } + + + @Override + //@Cacheable + public List queryAll(YxStoreAfterSalesQueryCriteria criteria) { + return baseMapper.selectList(QueryHelpPlus.getPredicate(StoreAfterSales.class, criteria)); + } + + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (YxStoreAfterSalesDto yxStoreAfterSales : all) { + Map map = new LinkedHashMap<>(); + map.put("订单号", yxStoreAfterSales.getOrderCode()); + map.put("退款金额", yxStoreAfterSales.getRefundAmount()); + map.put("服务类型0仅退款1退货退款", yxStoreAfterSales.getServiceType()); + map.put("申请原因", yxStoreAfterSales.getReasons()); + map.put("说明", yxStoreAfterSales.getExplains()); + map.put("说明图片->多个用逗号分割", yxStoreAfterSales.getExplainImg()); + map.put("物流公司编码", yxStoreAfterSales.getShipperCode()); + map.put("物流单号", yxStoreAfterSales.getDeliverySn()); + map.put("物流名称", yxStoreAfterSales.getDeliveryName()); + map.put("状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3退款成功", yxStoreAfterSales.getState()); + map.put("售后状态-0正常1用户取消2商家拒绝", yxStoreAfterSales.getSalesState()); + map.put("添加时间", yxStoreAfterSales.getCreateTime()); + map.put("逻辑删除", yxStoreAfterSales.getIsDel()); + map.put("用户id", yxStoreAfterSales.getUserId()); + map.put("商家收货人", yxStoreAfterSales.getConsignee()); + map.put("商家手机号", yxStoreAfterSales.getPhoneNumber()); + map.put("商家地址", yxStoreAfterSales.getAddress()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesStatusServiceImpl.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesStatusServiceImpl.java new file mode 100644 index 00000000..a66a5cb2 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/impl/StoreAfterSalesStatusServiceImpl.java @@ -0,0 +1,19 @@ +package co.yixiang.modules.sales.service.impl; + +import co.yixiang.common.service.impl.BaseServiceImpl; +import co.yixiang.modules.sales.domain.StoreAfterSalesStatus; +import co.yixiang.modules.sales.service.StoreAfterSalesStatusService; +import co.yixiang.modules.sales.service.mapper.StoreAfterSalesStatusMapper; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author : gzlv 2021/6/27 15:56 + */ +@Service +@AllArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class StoreAfterSalesStatusServiceImpl extends BaseServiceImpl implements StoreAfterSalesStatusService { +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesItemMapper.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesItemMapper.java new file mode 100644 index 00000000..a21ebd20 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesItemMapper.java @@ -0,0 +1,10 @@ +package co.yixiang.modules.sales.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.sales.domain.StoreAfterSalesItem; + +/** + * @author : gzlv 2021/6/27 15:53 + */ +public interface StoreAfterSalesItemMapper extends CoreMapper { +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesMapper.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesMapper.java new file mode 100644 index 00000000..51fd30e7 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesMapper.java @@ -0,0 +1,10 @@ +package co.yixiang.modules.sales.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.sales.domain.StoreAfterSales; + +/** + * @author : gzlv 2021/6/27 15:53 + */ +public interface StoreAfterSalesMapper extends CoreMapper { +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesStatusMapper.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesStatusMapper.java new file mode 100644 index 00000000..a7ce7d43 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/mapper/StoreAfterSalesStatusMapper.java @@ -0,0 +1,10 @@ +package co.yixiang.modules.sales.service.mapper; + +import co.yixiang.common.mapper.CoreMapper; +import co.yixiang.modules.sales.domain.StoreAfterSalesStatus; + +/** + * @author : gzlv 2021/6/27 15:52 + */ +public interface StoreAfterSalesStatusMapper extends CoreMapper { +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/service/vo/StoreAfterSalesVo.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/vo/StoreAfterSalesVo.java new file mode 100644 index 00000000..402bfb19 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/vo/StoreAfterSalesVo.java @@ -0,0 +1,122 @@ +package co.yixiang.modules.sales.service.vo; + +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.List; + +/** + * @author : gzlv 2021/6/28 0:43 + */ +@Data +public class StoreAfterSalesVo { + + /** id */ + @TableId(value = "uid", type = IdType.AUTO) + private Long id; + + /** 订单号 */ + private String orderCode; + + /** 退款金额 */ + private BigDecimal refundAmount; + + /** 服务类型0仅退款1退货退款 */ + private Integer serviceType; + + /** 申请原因 */ + private String reasons; + + /** 说明 */ + private String explains; + + /** 说明图片->多个用逗号分割 */ + private String explainImg; + + /** 物流单号 */ + private String deliverySn; + + /** 物流名称 */ + private String deliveryName; + + @ApiModelProperty(value = "快递公司编码") + private String shipperCode; + + /** 状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3退款成功 */ + private Integer state; + + /** 售后状态-0正常1用户取消2商家拒绝 */ + private Integer salesState; + + /** 添加时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp createTime; + + /** 逻辑删除 */ + private Integer isDel; + + /** 用户id */ + private Long userId; + + private List cartInfo; + + /** + * 收货人 + */ + private String consignee; + + /** + * 手机号 + */ + private String phoneNumber; + + /** + * 地址 + */ + private String address; + + + /** + * 审核时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp reviewTime; + + /** + * 发货时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp deliveryTime; + + /** + * 完成时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp completeTime; + + /** + * 审核失败时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp auditFailedTime; + + /** + * 撤销时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Timestamp revocationTime; + +} diff --git a/yshop-mall/src/main/java/co/yixiang/modules/sales/service/vo/YxStoreOrderCartInfoVo.java b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/vo/YxStoreOrderCartInfoVo.java new file mode 100644 index 00000000..5f852428 --- /dev/null +++ b/yshop-mall/src/main/java/co/yixiang/modules/sales/service/vo/YxStoreOrderCartInfoVo.java @@ -0,0 +1,46 @@ +package co.yixiang.modules.sales.service.vo; + +import co.yixiang.modules.cart.vo.YxStoreCartQueryVo; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author : gzlv 2021/6/27 22:40 + */ +@Data +public class YxStoreOrderCartInfoVo { + + @TableId + private Long id; + + + /** 订单id */ + private Long oid; + + + /** 购物车id */ + private Long cartId; + + + /** 商品ID */ + private Long productId; + + + /** 购买东西的详细信息 */ + private YxStoreCartQueryVo cartInfo; + + + /** 唯一id */ + @TableField(value = "`unique`") + private String unique; + + /** 是否能售后0不能1能 */ + private Integer isAfterSales; + + /** 可退價格 */ + private BigDecimal refundablePrice; + +} diff --git a/yshop-shop/src/main/java/co/yixiang/modules/sales/StoreAfterSalesController.java b/yshop-shop/src/main/java/co/yixiang/modules/sales/StoreAfterSalesController.java new file mode 100644 index 00000000..2b547bd4 --- /dev/null +++ b/yshop-shop/src/main/java/co/yixiang/modules/sales/StoreAfterSalesController.java @@ -0,0 +1,113 @@ +package co.yixiang.modules.sales; + +import co.yixiang.annotation.AnonymousAccess; +import co.yixiang.domain.PageResult; +import co.yixiang.dozer.service.IGenerator; +import co.yixiang.logging.aop.log.Log; +import co.yixiang.modules.mp.service.WeixinPayService; +import co.yixiang.modules.sales.domain.StoreAfterSales; +import co.yixiang.modules.sales.param.SalesCheckDto; +import co.yixiang.modules.sales.param.YxStoreAfterSalesDto; +import co.yixiang.modules.sales.service.StoreAfterSalesService; +import co.yixiang.modules.sales.param.YxStoreAfterSalesQueryCriteria; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.Map; + +/** + * @author : gzlv 2021/6/29 3:48 + */ +@Api(tags = "商城:售后管理") +@RestController +@RequestMapping("/api/yxStoreAfterSales") +@Slf4j +@SuppressWarnings("unchecked") +@AllArgsConstructor +public class StoreAfterSalesController { + + private final StoreAfterSalesService storeAfterSalesService; + private final WeixinPayService weixinPayService; + private final IGenerator generator; + + /** + * 审核 + */ + @Log("审核") + @ApiOperation("审核") + @PreAuthorize("@el.check('admin','yxStoreAfterSales:edit')") + @PostMapping(value = "/salesCheck") + public ResponseEntity salesCheck(@RequestBody SalesCheckDto salesCheckDto) { + return new ResponseEntity<>(storeAfterSalesService.salesCheck(salesCheckDto.getSalesId(), salesCheckDto.getOrderCode(), salesCheckDto.getApprovalStatus(), salesCheckDto.getConsignee(), salesCheckDto.getPhoneNumber(), salesCheckDto.getAddress()), HttpStatus.OK); + } + + /** + * 打款 + */ + @Log("打款") + @ApiOperation("打款") + @PostMapping(value = "/makeMoney") + @PreAuthorize("@el.check('admin','yxStoreAfterSales:edit')") + public ResponseEntity makeMoney(@RequestParam(value = "salesId") Long salesId, @RequestParam("orderCode") String orderCode) { + StoreAfterSales sales = storeAfterSalesService.makeMoney(salesId, orderCode); + BigDecimal bigDecimal = new BigDecimal("100"); + int payPrice = bigDecimal.multiply(sales.getRefundAmount()).intValue(); + weixinPayService.refundOrder(orderCode, payPrice); + return new ResponseEntity<>(HttpStatus.OK); + } + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('admin','yxStoreAfterSales:list')") + public void download(HttpServletResponse response, YxStoreAfterSalesQueryCriteria criteria) throws IOException { + storeAfterSalesService.download(generator.convert(storeAfterSalesService.queryAll(criteria), YxStoreAfterSalesDto.class), response); + } + + @GetMapping(value = "/sales/List") + @Log("查询售后") + @ApiOperation("查询售后") + @PreAuthorize("@el.check('admin','yxStoreAfterSales:list')") + public ResponseEntity> getYxStoreAfterSaless(YxStoreAfterSalesQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(storeAfterSalesService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增售后") + @ApiOperation("新增售后") + @PreAuthorize("@el.check('admin','yxStoreAfterSales:add')") + public ResponseEntity create(@Validated @RequestBody StoreAfterSales resources){ + return new ResponseEntity<>(storeAfterSalesService.save(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改售后") + @ApiOperation("修改售后") + @PreAuthorize("@el.check('admin','yxStoreAfterSales:edit')") + public ResponseEntity update(@Validated @RequestBody StoreAfterSales resources){ + storeAfterSalesService.updateById(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除售后") + @ApiOperation("删除售后") + @PreAuthorize("@el.check('admin','yxStoreAfterSales:del')") + @DeleteMapping + public ResponseEntity deleteAll(@RequestBody Long[] ids) { + Arrays.asList(ids).forEach(storeAfterSalesService::removeById); + return new ResponseEntity<>(HttpStatus.OK); + } + +} diff --git a/yshop-weixin/src/main/java/co/yixiang/modules/mp/service/WeixinPayService.java b/yshop-weixin/src/main/java/co/yixiang/modules/mp/service/WeixinPayService.java index 19964993..eccc72ca 100644 --- a/yshop-weixin/src/main/java/co/yixiang/modules/mp/service/WeixinPayService.java +++ b/yshop-weixin/src/main/java/co/yixiang/modules/mp/service/WeixinPayService.java @@ -125,7 +125,8 @@ public class WeixinPayService { orderRequest.setOutTradeNo(orderId); orderRequest.setTotalFee(payPrice); orderRequest.setSpbillCreateIp(IpUtil.getLocalIP()); - orderRequest.setNotifyUrl(this.getApiUrl() + "/api/wechat/notify"); +// orderRequest.setNotifyUrl(this.getApiUrl() + "/api/wechat/notify"); + orderRequest.setNotifyUrl("http://www.itxzz.top/api/wechat/notify"); orderRequest.setBody(body); orderRequest.setAttach(attach); @@ -183,8 +184,8 @@ public class WeixinPayService { wxPayRefundRequest.setOutRefundNo(orderSn); //退款金额 wxPayRefundRequest.setRefundFee(refundFee); - wxPayRefundRequest.setNotifyUrl(this.getApiUrl() + "/api/notify/refund"); - +// wxPayRefundRequest.setNotifyUrl(this.getApiUrl() + "/api/notify/refund"); + wxPayRefundRequest.setNotifyUrl("http://www.itxzz.top/api/wechat/notify"); try { wxPayService.refundV2(wxPayRefundRequest); } catch (WxPayException e) {