核销增加分销与积分奖励,后台核销新增rest调用api

This commit is contained in:
hupeng
2020-04-09 13:07:31 +08:00
parent 9432d7ef54
commit 668788bd40
5 changed files with 83 additions and 5 deletions

View File

@ -75,6 +75,8 @@ public interface YxStoreOrderService extends BaseService<YxStoreOrder> {
void takeOrder(String orderId,int uid);
void verificOrder(String orderId);
List<YxStoreOrderQueryVo> orderList(int uid,int type,int page,int limit);
//@WebMethod

View File

@ -592,6 +592,30 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<YxStoreOrderMapper,
}
/**
* 核销订单
* @param orderId
*/
@Override
public void verificOrder(String orderId) {
YxStoreOrderQueryVo order = getOrderInfo(orderId,0);
if(ObjectUtil.isNull(order)) throw new ErrorRequestException("订单不存在");
YxStoreOrder storeOrder = new YxStoreOrder();
storeOrder.setStatus(OrderInfoEnum.STATUS_2.getValue());
storeOrder.setId(order.getId());
yxStoreOrderMapper.updateById(storeOrder);
//增加状态
orderStatusService.create(order.getId(),"user_take_delivery","已核销");
//奖励积分
gainUserIntegral(order);
//分销计算
userService.backOrderBrokerage(order);
}
/**
* 申请退款
* @param param

View File

@ -12,6 +12,7 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.qrcode.QrCodeUtil;
import co.yixiang.annotation.AnonymousAccess;
import co.yixiang.aop.log.Log;
import co.yixiang.common.api.ApiResult;
import co.yixiang.common.web.controller.BaseController;
@ -757,13 +758,43 @@ public class StoreOrderController extends BaseController {
return ApiResult.ok(order);
}
order.setStatus(OrderInfoEnum.STATUS_2.getValue());
storeOrderService.updateById(order);
storeOrderService.verificOrder(order.getOrderId());
return ApiResult.ok("核销成功");
}
/**
* 后台订单核销用于远程调用
*/
@AnonymousAccess
@GetMapping("/order/admin/order_verific/{code}")
public ApiResult<Object> orderAminVerify(@PathVariable String code){
YxStoreOrder storeOrder = new YxStoreOrder();
storeOrder.setVerifyCode(code);
storeOrder.setIsDel(OrderInfoEnum.CANCEL_STATUS_0.getValue());
storeOrder.setPaid(OrderInfoEnum.PAY_STATUS_1.getValue());
storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_0.getValue());
YxStoreOrder order = storeOrderService.getOne(Wrappers.query(storeOrder));
if(order == null) return ApiResult.fail("核销的订单不存在或未支付或已退款");
if(order.getStatus() > 0) return ApiResult.fail("订单已经核销");
if(order.getCombinationId() > 0 && order.getPinkId() > 0){
YxStorePinkQueryVo storePink = storePinkService.getYxStorePinkById(order.getPinkId());
if(!OrderInfoEnum.PINK_STATUS_2.getValue().equals(storePink.getStatus())){
return ApiResult.fail("拼团订单暂未成功无法核销");
}
}
storeOrderService.verificOrder(order.getOrderId());
return ApiResult.ok("核销成功");
}
}

View File

@ -22,9 +22,12 @@ import co.yixiang.mp.service.WxMpTemplateMessageService;
import co.yixiang.mp.service.YxTemplateService;
import co.yixiang.mp.service.YxWechatTemplateService;
import co.yixiang.utils.OrderUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpStatus;
@ -32,7 +35,9 @@ 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 org.springframework.web.client.RestTemplate;
import java.text.MessageFormat;
import java.util.concurrent.TimeUnit;
/**
@ -45,6 +50,9 @@ import java.util.concurrent.TimeUnit;
@Slf4j
public class StoreOrderController {
@Value("${yshop.apiUrl}")
private String apiUrl;
private final YxStoreOrderService yxStoreOrderService;
private final YxStoreOrderStatusService yxStoreOrderStatusService;
@ -243,6 +251,8 @@ public class StoreOrderController {
if(OrderInfoEnum.PAY_STATUS_0.getValue().equals(storeOrderDTO.getPaid())){
throw new BadRequestException("订单未支付");
}
/**
if(storeOrderDTO.getStatus() > 0) throw new BadRequestException("订单已核销");
if(storeOrderDTO.getCombinationId() > 0 && storeOrderDTO.getPinkId() > 0){
@ -251,9 +261,19 @@ public class StoreOrderController {
throw new BadRequestException("拼团订单暂未成功无法核销");
}
}
**/
resources.setStatus(OrderInfoEnum.STATUS_2.getValue());
yxStoreOrderService.update(resources);
//远程调用API
RestTemplate rest = new RestTemplate();
String url = StrUtil.format(apiUrl+"/order/admin/order_verific/{}", resources.getVerifyCode());
String text = rest.getForObject(url, String.class);
JSONObject jsonObject = JSON.parseObject(text);
Integer status = jsonObject.getInteger("status");
String msg = jsonObject.getString("msg");
if(status != 200) throw new BadRequestException(msg);
return new ResponseEntity(HttpStatus.NO_CONTENT);

View File

@ -57,4 +57,5 @@ yshop:
express:
enable: true
appId: 1607734
appKey: 81f43a2e-f504-45c4-9b54-2637d59f8190
appKey: 81f43a2e-f504-45c4-9b54-2637d59f8190
apiUrl: http://127.0.0.1:8009/api