3/29
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.yxt.yythmall.api.refundorder;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2024/3/28 15:03
|
||||
*/
|
||||
@Data
|
||||
public class RefundOrder {
|
||||
private String id;
|
||||
private String sid;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
private String state;
|
||||
private String outTradeNo;//订单号
|
||||
private int source;//0
|
||||
private String name;
|
||||
private String amount;
|
||||
private String openId;//
|
||||
private String mainSid;//退款mainSid
|
||||
private String reason;//退款理由
|
||||
private String orderSid;//支付订单sid
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.yxt.yythmall.api.refundorder;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2024/3/28 15:03
|
||||
*/
|
||||
@Data
|
||||
public class RefundOrderDto {
|
||||
private String id;
|
||||
private String sid;
|
||||
private String createTime;
|
||||
private String state;
|
||||
private String outTradeNo;
|
||||
private String outRefundNo;
|
||||
private String source;
|
||||
private String name;
|
||||
private String amount;
|
||||
private String openId;
|
||||
private String mainSid;
|
||||
private String reason;
|
||||
private String refundTime;
|
||||
private String orderSid;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.yxt.yythmall.api.refundorder;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2024/3/28 15:04
|
||||
*/
|
||||
@Data
|
||||
public class RefundOrderQuery {
|
||||
private String name;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yxt.yythmall.api.refundorder;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2024/3/28 15:03
|
||||
*/
|
||||
@Data
|
||||
public class RefundOrderVo {
|
||||
private String id;
|
||||
private String sid;
|
||||
private String createTime;
|
||||
private String state;
|
||||
private String outTradeNo;
|
||||
private String source;
|
||||
private String name;
|
||||
private String amount;
|
||||
private String openId;
|
||||
private String mainSid;
|
||||
private String reason;
|
||||
private String refundTime;
|
||||
private String orderSid;
|
||||
}
|
||||
@@ -125,10 +125,11 @@ public class NewcomerRecoRecordService extends MybatisBaseService<NewcomerRecoRe
|
||||
List<RecommendNewUserBag> bags=recommendNewUserBagService.list(new QueryWrapper<RecommendNewUserBag>().eq("isGrounding","1"));
|
||||
RecommendNewUserBagVo bagVo=new RecommendNewUserBagVo();
|
||||
bagVo.setRemarks("");
|
||||
bagVo.setIconUrl("");
|
||||
if(bags.size()!=0){
|
||||
bagVo.setRemarks(bags.get(0).getRemarks());
|
||||
bagVo.setIconUrl(fileUploadComponent.getUrlPrefix()+bags.get(0).getIconUrl());
|
||||
}
|
||||
// bagVo.setIconUrl(fileUploadComponent.getUrlPrefix()+bags.get(0).getIconUrl());
|
||||
List<NewcomerRecoRecordVo> vos=baseMapper.recordList(customerSid);
|
||||
for (NewcomerRecoRecordVo newcomerRecoRecordVo : vos) {
|
||||
RecommendNewUserBag r= recommendNewUserBagService.getOne(new QueryWrapper<RecommendNewUserBag>().eq("sid",newcomerRecoRecordVo.getGiftBagSid()));
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.yxt.yythmall.biz.refundorder;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.yxt.yythmall.api.refundorder.RefundOrder;
|
||||
import com.yxt.yythmall.api.refundorder.RefundOrderVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2023/11/23 10:36
|
||||
*/
|
||||
@Mapper
|
||||
public interface RefundOrderMapper extends BaseMapper<RefundOrder> {
|
||||
IPage<RefundOrderVo> orderList(IPage<RefundOrder> page, @Param(Constants.WRAPPER) QueryWrapper<RefundOrder> qw);
|
||||
RefundOrderVo getOrderDetails(@Param("sid")String sid);
|
||||
//
|
||||
// @Select("SELECT " +
|
||||
// " ood.goodsName goodsName, " +
|
||||
// " ood.partNumber goodsNumber " +
|
||||
// "FROM ord_order oo " +
|
||||
// "LEFT JOIN ord_order_detail ood ON ood.orderSid=oo.sid " +
|
||||
// "WHERE oo.payStatus=4 AND oo.outTradeNo=#{tradeNo}")
|
||||
// List<RefundOrderGoodsItem> listGoodsInfoByOutTradeNo(@Param("tradeNo") String outTradeNo);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.yxt.yythmall.biz.refundorder.RefundOrderMapper">
|
||||
<!-- <where> ${ew.sqlSegment} </where>-->
|
||||
<!-- ${ew.customSqlSegment} -->
|
||||
|
||||
<select id="orderList" resultType="com.yxt.yythmall.api.ordorder.OrdOrderVo">
|
||||
select
|
||||
*
|
||||
from refund_order
|
||||
<where>
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
<select id="getOrderDetails" resultType="com.yxt.yythmall.api.ordorder.OrdOrderVo">
|
||||
select
|
||||
*
|
||||
from refund_order
|
||||
where sid=#{sid}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.yxt.yythmall.biz.refundorder;
|
||||
|
||||
import com.yxt.common.core.query.PagerQuery;
|
||||
import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.common.core.vo.PagerVo;
|
||||
import com.yxt.yythmall.api.refundorder.RefundOrderDto;
|
||||
import com.yxt.yythmall.api.refundorder.RefundOrderQuery;
|
||||
import com.yxt.yythmall.api.refundorder.RefundOrderVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2023/11/23 10:35
|
||||
*/
|
||||
@Api(tags = "退款 ")
|
||||
@RestController
|
||||
@RequestMapping("/refund")
|
||||
public class RefundOrderRest {
|
||||
@Autowired
|
||||
RefundOrderService refundOrderService;
|
||||
|
||||
|
||||
@PostMapping("/createOrder")
|
||||
@ApiOperation(value = "创建订单")
|
||||
public ResultBean createOrder(RefundOrderDto dto) {
|
||||
return refundOrderService.createOrder(dto);
|
||||
}
|
||||
|
||||
@PostMapping("/refundBusiness")
|
||||
@ApiOperation(value = "减库存")
|
||||
public ResultBean refundBusiness(@RequestBody String mainSid) {
|
||||
return refundOrderService.refundBusiness(mainSid);
|
||||
}
|
||||
@PostMapping("/isRefundBusiness")
|
||||
@ApiOperation(value = "退款业务")
|
||||
public ResultBean isRefundBusiness(@RequestBody String mainSid) {
|
||||
return refundOrderService.isRefundBusiness(mainSid);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package com.yxt.yythmall.biz.refundorder;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.yxt.common.base.config.component.FileUploadComponent;
|
||||
import com.yxt.common.base.service.MybatisBaseService;
|
||||
import com.yxt.common.base.utils.PagerUtil;
|
||||
import com.yxt.common.base.utils.StringUtils;
|
||||
import com.yxt.common.core.query.PagerQuery;
|
||||
import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.yythmall.api.lpkcustomer.LpkCustomerVo;
|
||||
import com.yxt.yythmall.api.lpkgoods.LpkGoods;
|
||||
import com.yxt.yythmall.api.ordorder.OrdOrder;
|
||||
import com.yxt.yythmall.api.ordorder.OrdOrderVo;
|
||||
import com.yxt.yythmall.api.ordorder.PayOrderVo;
|
||||
import com.yxt.yythmall.api.ordorderdetails.OrdOrderDetail;
|
||||
import com.yxt.yythmall.api.refundorder.RefundOrder;
|
||||
import com.yxt.yythmall.api.refundorder.RefundOrderDto;
|
||||
import com.yxt.yythmall.api.refundorder.RefundOrderQuery;
|
||||
import com.yxt.yythmall.api.vegetablecellar.VegetableCellar;
|
||||
import com.yxt.yythmall.api.vegetablecellar.VegetableCellarDto;
|
||||
import com.yxt.yythmall.api.vegetablecellar.vegeVo;
|
||||
import com.yxt.yythmall.biz.appletgiftbag.AppletGiftBagService;
|
||||
import com.yxt.yythmall.biz.lpkcustomer.LpkCustomerService;
|
||||
import com.yxt.yythmall.biz.lpkgoods.LpkGoodsService;
|
||||
import com.yxt.yythmall.biz.ordorder.OrdOrderMapper;
|
||||
import com.yxt.yythmall.biz.ordorder.OrdOrderService;
|
||||
import com.yxt.yythmall.biz.ordorderdetails.OrdOrderDetailMapper;
|
||||
import com.yxt.yythmall.biz.ordorderdetails.OrdOrderDetailService;
|
||||
import com.yxt.yythmall.biz.shoppingcart.ShoppingCartService;
|
||||
import com.yxt.yythmall.biz.vegetablecellar.VegetableCellarService;
|
||||
import com.yxt.yythmall.biz.wx.RequestMes;
|
||||
import com.yxt.yythmall.biz.wx.WxConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2023/11/23 10:36
|
||||
*/
|
||||
@Service
|
||||
public class RefundOrderService extends MybatisBaseService<RefundOrderMapper, RefundOrder> {
|
||||
|
||||
// private static final String OrderUrl = "https://supervise.yxtsoft.com/lpkapi/empcardgift/generateTopEmpCard?mainSid=";
|
||||
// private static final String or = "https://supervise.yxtsoft.com/lpkapi/vegetablecellar/addGoods?mainSid=";
|
||||
|
||||
@Autowired
|
||||
OrdOrderService ordOrderService;
|
||||
@Autowired
|
||||
OrdOrderDetailService ordOrderDetailService;
|
||||
@Autowired
|
||||
LpkGoodsService lpkGoodsService;
|
||||
@Autowired
|
||||
VegetableCellarService vegetableCellarService;
|
||||
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultBean createOrder(RefundOrderDto dto) {
|
||||
ResultBean rb=new ResultBean().fail();
|
||||
OrdOrder orderDetail = ordOrderService.getOne(new QueryWrapper<OrdOrder>().eq("sid",dto.getSid()));
|
||||
Map<String, Object> sendBody=buildMessageBody(orderDetail,dto.getReason());
|
||||
ResponseEntity<ResultBean> postForEntity = new RestTemplate().postForEntity("https://supervise.yxtsoft.com/wxPay/refund/createRefundOrder", sendBody, ResultBean.class);
|
||||
ResultBean<RefundOrder> rb1 = postForEntity.getBody();
|
||||
LinkedHashMap rb2 = (LinkedHashMap) postForEntity.getBody().getData();
|
||||
if (!rb1.getCode().equals("200")) {
|
||||
return rb1;
|
||||
}
|
||||
RefundOrder refundOrder=new RefundOrder();
|
||||
refundOrder.setOutTradeNo(rb2.get("outTradeNo").toString());
|
||||
refundOrder.setSource(orderDetail.getSource());
|
||||
refundOrder.setName(orderDetail.getName());
|
||||
refundOrder.setAmount(orderDetail.getTotalTee());
|
||||
refundOrder.setOpenId(orderDetail.getOpenId());
|
||||
refundOrder.setMainSid(rb2.get("mainSid").toString());
|
||||
refundOrder.setReason(dto.getReason());
|
||||
refundOrder.setOrderSid(orderDetail.getSid());
|
||||
refundOrder.setCreateTime(new Date());
|
||||
baseMapper.insert(refundOrder);
|
||||
//该订单状态
|
||||
orderDetail.setPayStatus(5);
|
||||
ordOrderService.updateById(orderDetail);
|
||||
//减库存
|
||||
refundBusiness(orderDetail.getMainSid());
|
||||
ResponseEntity<ResultBean> refundResponse = new RestTemplate().postForEntity("https://supervise.yxtsoft.com/wxPay/refund/reviewRefund?orderSid="+orderDetail.getSid(), sendBody, ResultBean.class);
|
||||
|
||||
|
||||
return rb.success().setData(1);
|
||||
}
|
||||
|
||||
public ResultBean refundBusiness(String mainSid) {
|
||||
ResultBean rb = new ResultBean().fail();
|
||||
OrdOrder order=ordOrderService.getOne(new QueryWrapper<OrdOrder>().eq("mainSid",mainSid));
|
||||
List<OrdOrderDetail> detailList=ordOrderDetailService.list(new QueryWrapper<OrdOrderDetail>().eq("orderSid",order.getSid()));
|
||||
for(OrdOrderDetail detail:detailList){
|
||||
LpkGoods cl=lpkGoodsService.getOne(new QueryWrapper<LpkGoods>().eq("sid",detail.getGoodsSid()));
|
||||
VegetableCellar vegetableCellar=vegetableCellarService.getOne(new QueryWrapper<VegetableCellar>().eq("customerSid",order.getUserSid())
|
||||
.eq("goodsSid",detail.getGoodsSid()).eq("affiliation",cl.getBrandId()));
|
||||
if(vegetableCellar.getGoodsNumber().equals(String.valueOf(detail.getPartNumber()))){
|
||||
vegetableCellar.setGoodsNumber(String.valueOf(Double.valueOf(vegetableCellar.getGoodsNumber())-Double.valueOf(detail.getPartNumber())));
|
||||
vegetableCellarService.updateById(vegetableCellar);
|
||||
}
|
||||
}
|
||||
return rb.success();
|
||||
}
|
||||
public ResultBean isRefundBusiness(String mainSid) {
|
||||
ResultBean rb = new ResultBean().fail();
|
||||
if(!true){
|
||||
OrdOrder order=ordOrderService.getOne(new QueryWrapper<OrdOrder>().eq("mainSid",mainSid));
|
||||
List<OrdOrderDetail> detailList=ordOrderDetailService.list(new QueryWrapper<OrdOrderDetail>().eq("orderSid",order.getSid()));
|
||||
List<vegeVo> vos =new ArrayList<>();
|
||||
for (OrdOrderDetail detail : detailList) {
|
||||
LpkGoods goods=lpkGoodsService.getOne(new QueryWrapper<LpkGoods>().eq("sid",detail.getGoodsSid()));
|
||||
vegeVo vo=new vegeVo();
|
||||
vo.setBrandId(String.valueOf(goods.getBrandId()));
|
||||
vo.setGoodsSid(detail.getGoodsSid());
|
||||
vo.setGoodsNumber(removeZeros(String.valueOf(detail.getPartNumber())));
|
||||
vos.add(vo);
|
||||
}
|
||||
VegetableCellarDto d=new VegetableCellarDto();
|
||||
d.setVos(vos);
|
||||
d.setCustomerSid(order.getUserSid());
|
||||
vegetableCellarService.save1Goods(d);
|
||||
return rb.setMsg("退款失败");
|
||||
}
|
||||
return rb.success();
|
||||
}
|
||||
|
||||
private static Map<String, Object> buildMessageBody(OrdOrder orderDetail,String reason) {
|
||||
//拼接base参数
|
||||
String name = "";
|
||||
//
|
||||
Map<String, Object> mp_template_msg = new HashMap<>();
|
||||
mp_template_msg.put("source", "0");
|
||||
mp_template_msg.put("amount", orderDetail.getTotalTee());
|
||||
mp_template_msg.put("openId", orderDetail.getOpenId());
|
||||
mp_template_msg.put("userSid", orderDetail.getUserSid());
|
||||
mp_template_msg.put("name", orderDetail.getName());
|
||||
mp_template_msg.put("reason", reason);
|
||||
mp_template_msg.put("orderSid", orderDetail.getMainSid());
|
||||
mp_template_msg.put("returnUrl","");
|
||||
return mp_template_msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 去除多余.0
|
||||
*
|
||||
* @param num
|
||||
* @return
|
||||
*/
|
||||
public static String removeZeros(String num) {
|
||||
if (num.indexOf(".") > 0) {
|
||||
// 去掉多余的0
|
||||
num = num.replaceAll("0+?$", "");
|
||||
// 如果最后一位是. 则去掉
|
||||
num = num.replaceAll("[.]$", "");
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user