售后流程

This commit is contained in:
chenjiajun
2021-07-05 09:30:20 +08:00
parent 616bb17291
commit eb42849b3e
40 changed files with 2859 additions and 849 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ target
.idea/
*.log
logs
*.DS_Store

View File

@ -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": ""
}
}
}

View File

@ -34,10 +34,10 @@
<artifactId>yshop-shop</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!--jwt-->
@ -46,28 +46,51 @@
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.jsonwebtoken</groupId>-->
<!-- <artifactId>jjwt-api</artifactId>-->
<!-- <version>${jjwt.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.jsonwebtoken</groupId>-->
<!-- <artifactId>jjwt-impl</artifactId>-->
<!-- <version>${jjwt.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.jsonwebtoken</groupId>-->
<!-- <artifactId>jjwt-jackson</artifactId>-->
<!-- <version>${jjwt.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.jsonwebtoken</groupId>-->
<!-- <artifactId>jjwt-api</artifactId>-->
<!-- <version>${jjwt.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.jsonwebtoken</groupId>-->
<!-- <artifactId>jjwt-impl</artifactId>-->
<!-- <version>${jjwt.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.jsonwebtoken</groupId>-->
<!-- <artifactId>jjwt-jackson</artifactId>-->
<!-- <version>${jjwt.version}</version>-->
<!-- </dependency>-->
<!-- quartz -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
</dependency>
<!--weixinpay-->
<dependency>
<groupId>co.yixiang</groupId>
<artifactId>yshop-weixin</artifactId>
<version>3.2</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -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

View File

@ -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;
/**
* <p>
@ -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<Object> 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<String, Object> 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"));
}
/**
* 优惠券 订单获取
*/

View File

@ -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<ConfirmOrderVo> confirm(@Validated @RequestBody ConfirmOrderParam param){
@ApiOperation(value = "订单确认", notes = "订单确认")
public ApiResult<ConfirmOrderVo> 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<Map<String,Object>> computedOrder(@Validated @RequestBody ComputeOrderParam param,
@PathVariable String key){
@ApiOperation(value = "计算订单金额", notes = "计算订单金额")
public ApiResult<Map<String, Object>> computedOrder(@Validated @RequestBody ComputeOrderParam param,
@PathVariable String key) {
YxUser yxUser = LocalUser.getUser();
Map<String,Object> map = orderSupplyService.check(yxUser.getUid(),key,param);
if(OrderLogEnum.EXTEND_ORDER.getValue().equals(map.get("status"))
Map<String, Object> 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<Map<String,Object>> create(@Valid @RequestBody OrderParam param,
@PathVariable String key){
@ApiOperation(value = "订单创建", notes = "订单创建")
public ApiResult<Map<String, Object>> create(@Valid @RequestBody OrderParam param,
@PathVariable String key) {
YxUser yxUser = LocalUser.getUser();
ComputeOrderParam computeOrderParam = new ComputeOrderParam();
BeanUtil.copyProperties(param,computeOrderParam);
Map<String,Object> map = orderSupplyService.check(yxUser.getUid(),key,computeOrderParam);
if(OrderLogEnum.EXTEND_ORDER.getValue().equals(map.get("status"))
BeanUtil.copyProperties(param, computeOrderParam);
Map<String, Object> 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<Map<String,Object>> pay(@Valid @RequestBody PayParam param){
Map<String,Object> map = new LinkedHashMap<>();
@ApiOperation(value = "订单支付", notes = "订单支付")
public ApiResult<Map<String, Object>> pay(@Valid @RequestBody PayParam param) {
Map<String, Object> 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<Object> 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<Object> 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<String, Object> 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<YxStoreOrderQueryVo> detail(@PathVariable String key){
@ApiOperation(value = "订单详情", notes = "订单详情")
public ApiResult<YxStoreOrderQueryVo> 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<Boolean> orderTake(@Validated @RequestBody DoOrderParam param){
@ApiOperation(value = "订单收货", notes = "订单收货")
public ApiResult<Boolean> 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<OrderCartInfoVo> product(@Validated @RequestBody ProductOrderParam param){
@ApiOperation(value = "订单产品信息", notes = "订单产品信息")
public ApiResult<OrderCartInfoVo> 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<Boolean> comment(@Valid @RequestBody ProductReplyParam param){
@ApiOperation(value = "订单评价", notes = "订单评价")
public ApiResult<Boolean> comment(@Valid @RequestBody ProductReplyParam param) {
YxUser user = LocalUser.getUser();
storeOrderService.orderComment(user,param.getUnique(),
YxStoreOrderCartInfo orderCartInfo = storeOrderCartInfoService
.getOne(Wrappers.<YxStoreOrderCartInfo>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<Boolean> comments(@Valid @RequestBody List<ProductReplyParam> param) {
YxUser user = LocalUser.getUser();
if (param.size() > 0) {
YxStoreOrderCartInfo orderCartInfo = storeOrderCartInfoService
.getOne(Wrappers.<YxStoreOrderCartInfo>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<Boolean> orderDel(@Validated @RequestBody DoOrderParam param){
@ApiOperation(value = "订单删除", notes = "订单删除")
public ApiResult<Boolean> 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<Object> refundReason(){
@ApiOperation(value = "订单退款理由", notes = "订单退款理由")
public ApiResult<Object> refundReason() {
ArrayList<String> 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<Boolean> refundVerify(@RequestBody RefundParam param){
@ApiOperation(value = "订单退款审核", notes = "订单退款审核")
public ApiResult<Boolean> 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<Boolean> cancelOrder(@Validated @RequestBody HandleOrderParam param){
@ApiOperation(value = "订单取消", notes = "订单取消")
public ApiResult<Boolean> 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<ExpressInfo> express( @RequestBody ExpressParam expressInfoDo){
@ApiOperation(value = "获取物流信息", notes = "获取物流信息")
public ApiResult<ExpressInfo> 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<Object> orderVerify( @RequestBody OrderVerifyParam param){
@ApiOperation(value = "订单核销", notes = "订单核销")
public ApiResult<Object> 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<List<String>> getSubscribeTemplate(){
@ApiOperation(value = "获取订阅消息模板ID", notes = "获取订阅消息模板ID")
public ApiResult<List<String>> getSubscribeTemplate() {
List<YxWechatTemplate> yxWechatTemplate = yxWechatTemplateService.lambdaQuery()
.eq(YxWechatTemplate::getType,"subscribe")
.eq(YxWechatTemplate::getType, "subscribe")
.eq(YxWechatTemplate::getStatus, ShopCommonEnum.IS_STATUS_1.getValue()).list();
List<String> temId = yxWechatTemplate.stream().map(tem-> tem.getTempid()).collect(Collectors.toList());
List<String> temId = yxWechatTemplate.stream().map(tem -> tem.getTempid()).collect(Collectors.toList());
return ApiResult.ok(temId);
}

View File

@ -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<Long> ids;
}

View File

@ -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<Boolean> collectDelFoot(@Validated @RequestBody CollectDelFootParam param){
if (CollectionUtil.isEmpty(param.getIds())){
throw new YshopException("参数非法");
}
productRelationService.collectDelFoot(param.getIds());
return ApiResult.ok();
}
/**
* 获取产品评论
*/

View File

@ -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<Boolean> 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<List<YxStoreOrderCartInfoVo>> checkOrderDetails(@PathVariable String key) {
return ApiResult.ok(storeAfterSalesService.checkOrderDetails(key));
}
@AppLog(value = "查看售后列表", type = 1)
@AuthCheck
@GetMapping("/storeAfterSales/list")
@ApiOperation(value = "售后列表", notes = "售后列表")
public ApiResult<Object> salesList(@RequestParam(value = "type", defaultValue = "0") int type,
@RequestParam(value = "page", defaultValue = "1") int page,
@RequestParam(value = "limit", defaultValue = "10") int limit) {
Map<String, Object> 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<StoreAfterSalesVo> detail(@PathVariable String key, @PathVariable Long id) {
Long uid = LocalUser.getUser().getUid();
if (StrUtil.isEmpty(key)) {
throw new YshopException("参数错误");
}
List<StoreAfterSalesVo> 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<List<StoreAfterSalesVo>> detail(@PathVariable String key) {
Long uid = LocalUser.getUser().getUid();
if (StrUtil.isEmpty(key)) {
throw new YshopException("参数错误");
}
List<StoreAfterSalesVo> 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<Boolean> 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<List<YxExpress>> 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<Boolean> 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<Boolean> 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);
}
}

View File

@ -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;
/** 数据库引擎 */

View File

@ -22,13 +22,14 @@ import java.util.List;
import java.util.Map;
/**
* @author hupeng
* @date 2020-05-13
*/
public interface YxStoreCouponUserService extends BaseService<YxStoreCouponUser>{
* @author hupeng
* @date 2020-05-13
*/
public interface YxStoreCouponUserService extends BaseService<YxStoreCouponUser> {
/**
* 获取当前用户优惠券数量
*
* @param uid uid
* @return int
*/
@ -38,33 +39,36 @@ public interface YxStoreCouponUserService extends BaseService<YxStoreCouponUser
/**
* 获取用户优惠券
* @param id 优惠券id
*
* @param id 优惠券id
* @param uid 用户id
* @return YxStoreCouponUser
*/
YxStoreCouponUser getCoupon(Integer id,Long uid);
YxStoreCouponUser getCoupon(Integer id, Long uid);
/**
* 获取满足条件的可用优惠券
*
* @param cartIds 购物车ids
* @return list
*/
List<StoreCouponUserVo> beUsableCouponList(Long uid,String cartIds);
List<StoreCouponUserVo> beUsableCouponList(Long uid, String cartIds);
/**
* 获取下单时候满足的优惠券
* @param uid uid
* @param price 总价格
*
* @param uid uid
* @param price 总价格
* @param productIds list
* @return list
*/
List<StoreCouponUserVo> getUsableCouponList(Long uid, double price, List<String> productIds);
/**
* 获取用户优惠券
*
* @param uid uid
* @return list
*/
@ -72,31 +76,46 @@ public interface YxStoreCouponUserService extends BaseService<YxStoreCouponUser
/**
* 添加优惠券记录
*
* @param uid 用户id
* @param cid 优惠券id
*/
void addUserCoupon(Long uid,Integer cid);
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(YxStoreCouponUserQueryCriteria criteria, Pageable pageable);
void addUserCoupon(Long uid, Integer cid);
/**
* 查询所有数据分页
* @param criteria 条件参数
* @return List<YxStoreCouponUserDto>
*/
* 查询数据分页
*
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String, Object>
*/
Map<String, Object> queryAll(YxStoreCouponUserQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
*
* @param criteria 条件参数
* @return List<YxStoreCouponUserDto>
*/
List<YxStoreCouponUser> queryAll(YxStoreCouponUserQueryCriteria criteria);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
* 导出数据
*
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<YxStoreCouponUserDto> all, HttpServletResponse response) throws IOException;
/**
* pc端查询优惠券
*
* @param uid 用户id
* @param page 当前页码
* @param limit 一页多少
* @param type
* @return /
*/
Map<String, Object> getUserPCCoupon(Long uid, int page, int limit, Integer type);
}

View File

@ -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<YxStoreCouponU
}
FileUtil.downloadExcel(list, response);
}
@Override
public Map<String, Object> getUserPCCoupon(Long uid, int page, int limit, Integer type) {
Page<YxStoreCouponUser> yxStoreCouponUserPage = new Page<>(page, limit);
yxStoreCouponUserMapper.selectPage(yxStoreCouponUserPage,Wrappers.<YxStoreCouponUser>lambdaQuery()
.eq(YxStoreCouponUser::getUid,uid).eq(YxStoreCouponUser::getStatus,type));
List<YxStoreCouponUserQueryVo> 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<String,Object> map = new HashMap<>();
map.put("list",storeCouponUserQueryVoList);
map.put("total",yxStoreCouponUserPage.getTotal());
map.put("totalPage",yxStoreCouponUserPage.getPages());
return map;
}
}

View File

@ -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));

View File

@ -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<YxStoreOrder>{
/**
* 订单评价
* @param orderCartInfo
* @param user user
* @param unique 订单orderCart唯一值
* @param comment 评论内容
@ -45,7 +47,7 @@ public interface YxStoreOrderService extends BaseService<YxStoreOrder>{
* @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);
/**

View File

@ -68,6 +68,7 @@ public class YxStoreOrderCartInfoServiceImpl extends BaseServiceImpl<StoreOrderC
info.setProductId(cart.getProductId());
info.setCartInfo(JSONObject.toJSON(cart).toString());
info.setUnique(IdUtil.simpleUUID());
info.setIsAfterSales(1);
list.add(info);
}

View File

@ -85,4 +85,9 @@ public interface YxStoreProductRelationService extends BaseService<YxStoreProduc
void download(List<YxStoreProductRelationDto> all, HttpServletResponse response) throws IOException;
/**
* 批量删除
* @param ids /
*/
void collectDelFoot(List<Long> ids);
}

View File

@ -166,4 +166,9 @@ public class YxStoreProductRelationServiceImpl extends BaseServiceImpl<YxStorePr
}
FileUtil.downloadExcel(list, response);
}
@Override
public void collectDelFoot(List<Long> ids) {
yxStoreProductRelationMapper.deleteBatchIds(ids);
}
}

View File

@ -30,7 +30,7 @@ import java.util.List;
@Repository
public interface YxStoreProductRelationMapper extends CoreMapper<YxStoreProductRelation> {
@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")

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<ProsuctParam> productParamList;
}

View File

@ -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;
}

View File

@ -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<Timestamp> time;
/** 状态 0已提交等待平台审核 1平台已审核 等待用户发货/退款 2 用户已发货 3已完成 */
private Integer state;
/** 服务类型0仅退款1退货退款 */
private Integer serviceType;
}

View File

@ -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<StoreAfterSalesItem> {
}

View File

@ -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<StoreAfterSales> {
/**
* 创建售后订单
*
* @param userId 用户id
* @param nickname 用户昵称
* @param storeAfterSalesParam /
*/
void applyForAfterSales(Long userId, String nickname, StoreAfterSalesParam storeAfterSalesParam);
/**
* 查询订单详情
* @param key 订单号
*/
List<YxStoreOrderCartInfoVo> checkOrderDetails(String key);
/**
* 查询列表
* @param uid 用户id
* @param status 状态
* @param page 页
* @param orderCode
* @param limit 数量
* @return
*/
Map<String, Object> salesList(Long uid, Integer status, Integer page, String orderCode, Integer limit);
/**
* 查询详情
* @param key 订单号
* @param id
* @param uid 用户id
*/
List<StoreAfterSalesVo> 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<String,Object>
*/
Map<String, Object> queryAll(YxStoreAfterSalesQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<YxStoreAfterSalesDto>
*/
List<StoreAfterSales> queryAll(YxStoreAfterSalesQueryCriteria criteria);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<YxStoreAfterSalesDto> all, HttpServletResponse response) throws IOException;
}

View File

@ -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<StoreAfterSalesStatus> {
}

View File

@ -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<StoreAfterSalesItemMapper, StoreAfterSalesItem> implements StoreAfterSalesItemService {
}

View File

@ -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<StoreAfterSalesMapper, StoreAfterSales> 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.<YxStoreOrder>lambdaQuery().eq(YxStoreOrder::getOrderId, storeAfterSalesParam.getOrderCode()).eq(YxStoreOrder::getUid, userId));
checkOrder(yxStoreOrder);
//商品除去优惠后的总价格
BigDecimal totalPrice = BigDecimal.ZERO;
//拿到所有的商品
List<YxStoreOrderCartInfo> yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.<YxStoreOrderCartInfo>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<YxStoreOrderCartInfoVo> checkOrderDetails(String key) {
List<YxStoreOrderCartInfo> yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.<YxStoreOrderCartInfo>lambdaQuery().eq(YxStoreOrderCartInfo::getOid, key));
YxStoreOrder yxStoreOrder = storeOrderMapper.selectById(key);
List<YxStoreOrderCartInfoVo> 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<String, Object> salesList(Long uid, Integer status, Integer page, String orderCode, Integer limit) {
Page<StoreAfterSales> storeAfterSalesPage = new Page<>(page, limit);
List<Integer> 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.<StoreAfterSales>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<StoreAfterSalesVo> storeAfterSalesVos = generator.convert(storeAfterSalesPage.getRecords(), StoreAfterSalesVo.class);
Map<String, Object> 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<StoreAfterSalesVo> getStoreInfo(String key, Long id, Long uid) {
List<StoreAfterSales> storeAfterSales = baseMapper.selectList(Wrappers.<StoreAfterSales>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<StoreAfterSalesItem> storeAfterSalesItems = storeAfterSalesItemMapper.selectList(Wrappers.<StoreAfterSalesItem>lambdaQuery().eq(StoreAfterSalesItem::getStoreAfterSalesId, storeAfterSalesVo.getId()));
List<YxStoreCartQueryVo> cartInfo = storeAfterSalesItems.stream()
.map(cart -> JSON.parseObject(cart.getCartInfo(), YxStoreCartQueryVo.class))
.collect(Collectors.toList());
storeAfterSalesVo.setCartInfo(cartInfo);
List<StoreAfterSalesStatus> storeAfterSalesStatuses = storeAfterSalesStatusMapper.selectList(Wrappers.<StoreAfterSalesStatus>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.<StoreAfterSales>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.<YxStoreOrder>lambdaQuery().eq(YxStoreOrder::getOrderId, key));
yxStoreOrder.setStatus(-2);
storeOrderMapper.updateById(yxStoreOrder);
List<YxStoreOrderCartInfo> yxStoreOrderCartInfos = storeOrderCartInfoMapper.selectList(Wrappers.<YxStoreOrderCartInfo>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.<StoreAfterSales>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.<StoreAfterSales>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.<StoreAfterSales>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.<StoreAfterSales>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.<YxStoreOrder>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<String, Object> queryAll(YxStoreAfterSalesQueryCriteria criteria, Pageable pageable) {
Page<StoreAfterSales> storeAfterSalesPage = new Page<>(pageable.getPageNumber(), pageable.getPageSize());
LambdaQueryWrapper<StoreAfterSales> eq = Wrappers.<StoreAfterSales>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<StoreAfterSalesVo> storeAfterSalesVos = generator.convert(storeAfterSalesPage.getRecords(), StoreAfterSalesVo.class);
Map<String, Object> 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<StoreAfterSales> queryAll(YxStoreAfterSalesQueryCriteria criteria) {
return baseMapper.selectList(QueryHelpPlus.getPredicate(StoreAfterSales.class, criteria));
}
@Override
public void download(List<YxStoreAfterSalesDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (YxStoreAfterSalesDto yxStoreAfterSales : all) {
Map<String, Object> 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);
}
}

View File

@ -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<StoreAfterSalesStatusMapper, StoreAfterSalesStatus> implements StoreAfterSalesStatusService {
}

View File

@ -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<StoreAfterSalesItem> {
}

View File

@ -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<StoreAfterSales> {
}

View File

@ -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<StoreAfterSalesStatus> {
}

View File

@ -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<YxStoreCartQueryVo> 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;
}

View File

@ -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;
}

View File

@ -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<Map<String, Object>> 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<Object> create(@Validated @RequestBody StoreAfterSales resources){
return new ResponseEntity<>(storeAfterSalesService.save(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改售后")
@ApiOperation("修改售后")
@PreAuthorize("@el.check('admin','yxStoreAfterSales:edit')")
public ResponseEntity<Object> 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<Object> deleteAll(@RequestBody Long[] ids) {
Arrays.asList(ids).forEach(storeAfterSalesService::removeById);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@ -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) {