Commit bc188748 by zhengyunfei

Merge remote-tracking branch 'origin/master'

parents 6ab9279e 22caa4e0
......@@ -40,7 +40,6 @@ public class WxController {
}
/**
* 微信支付
*
......@@ -65,15 +64,13 @@ public class WxController {
}
/**
* 回调测试
*/
@RequestMapping(value = "/testNotifyOk/{id}", method = RequestMethod.GET)
@ResponseBody
public String testNotifyOk(@PathVariable Integer id){
if(id == null) return null;
public String testNotifyOk(@PathVariable Integer id) {
if (id == null) return null;
this.wxServiceImpl.handleNotifyOk(id);
......@@ -100,20 +97,17 @@ public class WxController {
@RequestMapping(value = "/wxRefund", method = RequestMethod.POST)
public Result wxRefund(Integer userId, Integer orderId, HttpServletRequest request) {
try {
return wxService.wxRefund(userId, orderId,"", request);
return wxService.wxRefund(userId, orderId, "", request);
} catch (Exception e) {
return new Result(103);
}
}
// @RequestMapping(value = "/asd", method = {RequestMethod.POST, RequestMethod.GET})
// public void asd(String outTradeNo) throws IOException, JDOMException {
// wxService.asd(outTradeNo);
// }
}
\ No newline at end of file
......@@ -339,7 +339,7 @@ public class OrderMainController {
@ResponseBody
public Result refundReceive(@RequestBody JSONObject json){
OrderMain user = JSONObject.toJavaObject(json,OrderMain.class);
return this.orderService.refundReceive(user);
return this.orderService.refundReceive(user, 4);
}
/**
......
......@@ -30,6 +30,8 @@ public class OrderMain {
// 关联查询对象: 关联用户表
@TableField(exist = false)
private Customer customer;
@TableField(exist = false)
private OrderRefund orderRefund;
//提交订单校验错误信息
@TableField(exist = false)
......@@ -76,6 +78,8 @@ public class OrderMain {
//数据库字段
private Integer id; // id主键
@TableField(exist = false)
private Integer zid; // id主键
private Integer customerid; // 客户id
private Integer productid; // 商品id,关联商品信息表id
private Integer addressid;//地址id,关联地址表
......
package com.yunniu.farming.webadmin.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName(value = "order_refund")
public class OrderRefund implements Serializable {
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 订单主表id
*/
@TableField(value = "order_mian_id")
private Long orderMianId;
/**
* 退款类型(1:仅退款,2退货退款)
*/
@TableField(value = "refund_type")
private String refundType;
/**
* 是否部分退(0是,1否)
*/
@TableField(value = "portion")
private String portion;
/**
* 退款编码
*/
@TableField(value = "refund_code")
private String refundCode;
/**
* 退款状态(1退款申请,2申请通过,3申请拒绝,4待退货,5退款成功,6待退款)
*/
@TableField(value = "refund_status")
private String refundStatus;
/**
* 退款金额
*/
@TableField(value = "refund_money")
private Double refundMoney;
/**
* 退款申请时间
*/
@TableField(value = "refund_time")
private Date refundTime;
/**
* 退款完成时间
*/
@TableField(value = "refund_suc_time")
private Date refundSucTime;
/**
* 退款原因
*/
@TableField(value = "refund_reason")
private String refundReason;
/**
* 退款图片
*/
@TableField(value = "refund_img")
private String refundImg;
/**
* 退款详情
*/
@TableField(value = "refund_detail")
private String refundDetail;
}
\ No newline at end of file
......@@ -43,9 +43,9 @@ public class OrderSub {
@JsonInclude(JsonInclude.Include.NON_NULL)
private String sdef1; //自定义项1 退款状态 1申请退款,2申请成功,3申请拒绝,4退款成功
@JsonInclude(JsonInclude.Include.NON_NULL)
private String sdef2; //自定义项2
private String sdef2; //自定义项2 退款成功数量
@JsonInclude(JsonInclude.Include.NON_NULL)
private String sdef3; //自定义项3
private String sdef3; //自定义项3 退款申请中的数量
@JsonInclude(JsonInclude.Include.NON_NULL)
private String sdef4; //自定义项4
@JsonInclude(JsonInclude.Include.NON_NULL)
......
......@@ -4,16 +4,11 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yunniu.farming.util.StringHelper;
import com.yunniu.farming.webadmin.dao.GroupBuyDao;
import com.yunniu.farming.webadmin.dao.GroupOrderDao;
import com.yunniu.farming.webadmin.dao.OrderMainDao;
import com.yunniu.farming.webadmin.dao.OrderSubDao;
import com.yunniu.farming.webadmin.model.GroupBuy;
import com.yunniu.farming.webadmin.model.GroupOrder;
import com.yunniu.farming.webadmin.model.OrderMain;
import com.yunniu.farming.webadmin.model.OrderSub;
import com.yunniu.farming.webadmin.dao.*;
import com.yunniu.farming.webadmin.model.*;
import com.yunniu.farming.webadmin.service.GroupOrderService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.ast.Var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -40,15 +35,18 @@ public class GroupOrderServiceImpl implements GroupOrderService {
private OrderMainDao orderMainDao;
@Autowired
private OrderSubDao orderSubDao;
@Autowired
private OrderRefundMapper refundMapper;
/**
* 保存团购订单
*
* @param item
* @return
*/
@Override
public GroupOrder addGroupOrder(OrderMain item) {
if (item.getAreaId() == null){
if (item.getAreaId() == null) {
throw new RuntimeException("缺少小区id参数");
}
if (item.getGroupBuyId() == null) {
......@@ -82,7 +80,7 @@ public class GroupOrderServiceImpl implements GroupOrderService {
order.setCreateTime(new Date());
orderDao.insert(order);
return order;
}else {
} else {
groupOrder.setGroupSize(groupOrder.getGroupSize() + 1);
if (Objects.equals(groupOrder.getGroupSize(), groupBuy.getGroupSize())) {
groupOrder.setGroupStatus("1");
......@@ -94,6 +92,7 @@ public class GroupOrderServiceImpl implements GroupOrderService {
/**
* 查询团购订单列表
*
* @param item
* @return
*/
......@@ -105,13 +104,14 @@ public class GroupOrderServiceImpl implements GroupOrderService {
/**
* 团购订单详情
*
* @param id
* @return
*/
@Override
public GroupOrder findById(Long id) {
GroupOrder order = orderDao.detailById(id);
if (order.getSuccessTime()!= null) {
if (order.getSuccessTime() != null) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
order.setSuccessTimeStr(formatter.format(order.getSuccessTime()));
}
......@@ -120,6 +120,7 @@ public class GroupOrderServiceImpl implements GroupOrderService {
/**
* 团购订单用户信息列表
*
* @param item
* @return
*/
......@@ -131,6 +132,7 @@ public class GroupOrderServiceImpl implements GroupOrderService {
/**
* 购买商品列表
*
* @param item 用户列表id
* @return
*/
......@@ -141,18 +143,28 @@ public class GroupOrderServiceImpl implements GroupOrderService {
/**
* 退款回调修改退款状态
*
* @param outRefundNo
* @return
*/
@Override
public boolean updateRefundStatus(String outRefundNo) {
OrderMain order = orderDao.getBySdef1(outRefundNo);
OrderRefund orderRefund = refundMapper.selectOne(Wrappers.<OrderRefund>lambdaQuery()
.eq(OrderRefund::getRefundCode, outRefundNo)
.eq(OrderRefund::getRefundStatus, 6));
orderRefund.setRefundStatus("5");
int update = refundMapper.updateById(orderRefund);
OrderMain order = orderMainDao.selectById(orderRefund.getOrderMianId());
if (orderRefund.getPortion().equals("1")) {
order.setIrefundstatus(OrderMain.STATUS_REFUND_SUC);
order.setIstatus(OrderMain.STATUS_COMPLETE);
int update = orderMainDao.updateById(order);
orderMainDao.updateById(order);
}
List<OrderSub> orderSubs = this.orderSubDao.selectList(Wrappers.<OrderSub>lambdaQuery().eq(OrderSub::getMainid, order.getId()).eq(OrderSub::getSdef1, 2));
orderSubs.forEach(sub->{
orderSubs.forEach(sub -> {
sub.setSdef1("4");
sub.setSdef2(sub.getSdef3());
sub.setSdef3("0");
orderSubDao.updateById(sub);
});
if (update > 0) {
......@@ -188,6 +200,7 @@ public class GroupOrderServiceImpl implements GroupOrderService {
/**
* 完成
*
* @param id
* @return
*/
......@@ -200,6 +213,7 @@ public class GroupOrderServiceImpl implements GroupOrderService {
/**
* 支付成功后判断团购订单是否成团
*
* @param curOrder
*/
public void isSuccess(OrderMain curOrder) {
......
......@@ -2,24 +2,21 @@ package com.yunniu.farming.webadmin.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yunniu.farming.result.Result;
import com.yunniu.farming.util.DateTools;
import com.yunniu.farming.util.DateUtils;
import com.yunniu.farming.util.StringHelper;
import com.yunniu.farming.util.WxPayAppUtils;
import com.yunniu.farming.webadmin.dao.CustomerDao;
import com.yunniu.farming.webadmin.dao.IntegralrecDao;
import com.yunniu.farming.webadmin.dao.OrderMainDao;
import com.yunniu.farming.webadmin.dao.OrderSubDao;
import com.yunniu.farming.webadmin.model.GroupOrder;
import com.yunniu.farming.webadmin.model.Integralrec;
import com.yunniu.farming.webadmin.model.OrderMain;
import com.yunniu.farming.webadmin.model.OrderSub;
import com.yunniu.farming.webadmin.dao.*;
import com.yunniu.farming.webadmin.model.*;
import com.yunniu.farming.webadmin.service.GroupOrderService;
import com.yunniu.farming.webadmin.service.WxService;
import com.yunniu.farming.wx.WxConfigUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -54,6 +51,8 @@ public class OrderMainServiceImpl {
@Autowired
private GroupOrderService orderService;
@Autowired
private OrderRefundMapper refundMapper;
@Autowired
@Lazy
......@@ -62,6 +61,7 @@ public class OrderMainServiceImpl {
/**
* 分页查询所有数据
*
* @return
*/
public List<OrderMain> selectByParamPageList(OrderMain doc) {
......@@ -71,7 +71,6 @@ public class OrderMainServiceImpl {
/**
* FRICE TODO 带参 常规查询
*
*/
public List<OrderMain> findByParam(OrderMain doc) {
return this.orderMainDao.selectByParam(doc);
......@@ -79,11 +78,10 @@ public class OrderMainServiceImpl {
/**
* 根据id删除用户
*
*/
public Result deleteByid(int id) {
int i = this.orderMainDao.deleteById(id);
if(i > 0){
if (i > 0) {
return Result.success("删除成功");
}
return Result.error();
......@@ -98,9 +96,9 @@ public class OrderMainServiceImpl {
}
/**
* 创建订单
*
* @return
*/
@Transactional(rollbackFor = Exception.class)
......@@ -108,7 +106,7 @@ public class OrderMainServiceImpl {
if (item.getId() == null) {
if (item.getItype() != null && item.getItype().equals(OrderMain.ITYPE_GROUP)){
if (item.getItype() != null && item.getItype().equals(OrderMain.ITYPE_GROUP)) {
GroupOrder order = orderService.addGroupOrder(item);
item.setGroupOrderId(order.getId());
}
......@@ -148,18 +146,18 @@ public class OrderMainServiceImpl {
}
/**
* 创建订单
*
* @return
*/
public Result addIntOrder(OrderMain item) {
if(item.getDactscore() == null || item.getDactscore() <= 0){
if (item.getDactscore() == null || item.getDactscore() <= 0) {
return Result.error("创建订单失败");
}
if (item.getItype().equals(OrderMain.ITYPE_GROUP)){
if (item.getItype().equals(OrderMain.ITYPE_GROUP)) {
GroupOrder order = orderService.addGroupOrder(item);
item.setGroupOrderId(order.getId());
}
......@@ -197,8 +195,6 @@ public class OrderMainServiceImpl {
}
/**
* @编辑
*/
......@@ -208,23 +204,23 @@ public class OrderMainServiceImpl {
OrderMain orderMain = this.orderMainDao.selectById(doc.getId());
if (orderMain == null){
if (orderMain == null) {
return Result.error("订单信息不存在");
}
//判断用户积分是否足够
if(doc.getDactscore() != null){
if (doc.getDactscore() != null) {
// 查询该用户的积分
Integralrec integralrec = new Integralrec();
integralrec.setCustomerid(orderMain.getCustomerid());
Double aDouble = this.integralrecDao.sumIntegral(integralrec);
if(aDouble == null || aDouble < 0) return Result.error("用户积分不足");
if (aDouble == null || aDouble < 0) return Result.error("用户积分不足");
// 用户收入积分减去支付积分要大于订单积分价格
// 用户余额要大于支付额
if((aDouble!=null ? aDouble : 0) < doc.getDactscore()) {
if ((aDouble != null ? aDouble : 0) < doc.getDactscore()) {
return Result.error("积分不足");
}
......@@ -232,7 +228,7 @@ public class OrderMainServiceImpl {
int i = this.orderMainDao.updateById(doc);
if(i > 0){
if (i > 0) {
return Result.success("修改成功");
}
......@@ -241,7 +237,6 @@ public class OrderMainServiceImpl {
}
//根据多参数查询订单数量
public int findOrderNum(OrderMain orderMain) {
return orderMainDao.countOrderNum(orderMain);
......@@ -255,7 +250,7 @@ public class OrderMainServiceImpl {
//更改订单服务中
public Result updateFwStatus(OrderMain order) {
if(order.getId() == null){
if (order.getId() == null) {
return Result.error();
}
......@@ -272,7 +267,7 @@ public class OrderMainServiceImpl {
//更改订单已完成
public Result updateOkStatus(OrderMain order) {
if(order.getId() == null){
if (order.getId() == null) {
return Result.error();
}
......@@ -294,17 +289,20 @@ public class OrderMainServiceImpl {
*/
@Transactional(rollbackFor = Exception.class)
public Result refundApplicationPass(OrderMain order) {
if(order.getId() == null){
if (order.getId() == null) {
return Result.error();
}
OrderMain orderMain = this.orderMainDao.selectById(order.getId());
if (orderMain.getIrefundstatus().equals(OrderMain.STATUS_REFUND_ONLY)) {
this.refundReceive(orderMain);
// OrderMain orderMain = this.orderMainDao.selectById(order.getId());
OrderRefund orderRefund = refundMapper.selectOne(Wrappers.<OrderRefund>lambdaQuery()
.eq(OrderRefund::getOrderMianId, order.getId())
.eq(OrderRefund::getRefundStatus, 1));
if (orderRefund.getRefundType().equals("1")) {
this.refundReceive(order, 1);
} else {
orderMain.setIrefundstatus(OrderMain.STATUS_RETURN_GOODS);
this.orderMainDao.updateById(orderMain);
orderRefund.setRefundStatus("4");
refundMapper.updateById(orderRefund);
List<OrderSub> orderSubs = this.orderSubDao.selectList(Wrappers.<OrderSub>lambdaQuery().eq(OrderSub::getMainid, order.getId()).eq(OrderSub::getSdef1, 1));
orderSubs.forEach(sub->{
orderSubs.forEach(sub -> {
sub.setSdef1("2");
orderSubDao.updateById(sub);
});
......@@ -317,14 +315,20 @@ public class OrderMainServiceImpl {
*/
@Transactional(rollbackFor = Exception.class)
public Result refundApplicationRefuse(OrderMain order) {
if(order.getId() == null){
if (order.getId() == null) {
return Result.error();
}
order.setIrefundstatus(OrderMain.STATUS_REFUND_REFUSE);
this.orderMainDao.updateById(order);
OrderRefund orderRefund = refundMapper.selectOne(Wrappers.<OrderRefund>lambdaQuery()
.eq(OrderRefund::getOrderMianId, order.getId())
.eq(OrderRefund::getRefundStatus, 1));
orderRefund.setRefundStatus("3");
refundMapper.updateById(orderRefund);
List<OrderSub> orderSubs = this.orderSubDao.selectList(Wrappers.<OrderSub>lambdaQuery().eq(OrderSub::getMainid, order.getId()).eq(OrderSub::getSdef1, 1));
orderSubs.forEach(sub->{
orderSubs.forEach(sub -> {
sub.setSdef1("3");
sub.setSdef3("0");
orderSubDao.updateById(sub);
});
return Result.success("成功");
......@@ -332,14 +336,20 @@ public class OrderMainServiceImpl {
/**
* 已收到退回货物,开始退款
*
* @param order
* @param type 1仅退款, 4 退货退款
* @return
*/
@Transactional(rollbackFor = Exception.class)
public Result refundReceive(OrderMain order) {
public Result refundReceive(OrderMain order, Integer type) {
// 根据id获取订单信息
OrderMain orderMain = this.orderMainDao.selectById(order.getId());
orderMain.setIrefundstatus(OrderMain.STATUS_REFUND);
OrderRefund orderRefund = refundMapper.selectOne(Wrappers.<OrderRefund>lambdaQuery()
.eq(OrderRefund::getOrderMianId, order.getId())
.eq(OrderRefund::getRefundStatus, type));
orderRefund.setRefundStatus("6");
refundMapper.updateById(orderRefund);
this.orderMainDao.updateById(orderMain);
log.info("收货成功,开始退款:{}", JSON.toJSONString(orderMain));
try {
......@@ -353,14 +363,14 @@ public class OrderMainServiceImpl {
@Transactional(rollbackFor = Exception.class)
public Result cancelOrder(OrderMain order) {
if(order.getId() == null){
if (order.getId() == null) {
return Result.error();
}
OrderMain orderMain = this.orderMainDao.selectById(order.getId());
//已支付订单 无法取消
if(orderMain.getIpaystatus().equals(OrderMain.PAY_STATUS_OK)){
if (orderMain.getIpaystatus().equals(OrderMain.PAY_STATUS_OK)) {
try {
wxService.wxRefund(orderMain.getCustomerid(), orderMain.getId(), "用户申请退款", null);
} catch (Exception e) {
......@@ -378,8 +388,6 @@ public class OrderMainServiceImpl {
}
//app支付
public Result appWxPay(Integer userId, Integer orderId, HttpServletRequest request) throws Exception {
OrderMain order = orderMainDao.selectByPrimaryKey(orderId);
......@@ -387,7 +395,7 @@ public class OrderMainServiceImpl {
return new Result(102);
}
//商品名称封装
String prodNames = "Q&A."+order.getSorderno();
String prodNames = "Q&A." + order.getSorderno();
DecimalFormat decimalFormat = new DecimalFormat("###################");
......@@ -407,7 +415,7 @@ public class OrderMainServiceImpl {
//将订单信息也返回页面
Map<String, Object> mr = new HashMap<String, Object>();
mr.put("order_id", order.getId());
mr.put("result_code",wxPayData.get("result_code"));
mr.put("result_code", wxPayData.get("result_code"));
//将状态码属性移除
wxPayData.remove("result_code");
......@@ -419,11 +427,10 @@ public class OrderMainServiceImpl {
}
//商品 订单逻辑处理
protected void handleCommProuctOrder(OrderMain co) {
if(co == null) return;
if (co == null) return;
// 支付回调标志,防止 多次回调
if (StringUtils.isEmpty(co.getSdef4())) {
......@@ -437,7 +444,7 @@ public class OrderMainServiceImpl {
this.update(co);
//判断是否 有抵扣的积分
if(co.getDactscore() != null && co.getDactscore() > 0) {
if (co.getDactscore() != null && co.getDactscore() > 0) {
//扣除用户抵扣所用的积分
Integralrec integralrec = new Integralrec();
integralrec.setDexpend(co.getDactscore());
......@@ -452,13 +459,13 @@ public class OrderMainServiceImpl {
//奖励用户下单返利积分 1元= 10积分
if(co.getDactmoney() != null && co.getDactmoney() > 0) {
if (co.getDactmoney() != null && co.getDactmoney() > 0) {
//保留整数位
double floor = Math.floor(co.getDactmoney());
double dincome = floor * 10;
if(dincome > 0){
if (dincome > 0) {
//增加积分收入记录
Integralrec inte = new Integralrec();
inte.setDincome(dincome);
......@@ -479,7 +486,7 @@ public class OrderMainServiceImpl {
}
//积分支付
public Result integralPay(Integer userId,Integer orderId) {
public Result integralPay(Integer userId, Integer orderId) {
OrderMain ord = orderMainDao.selectByPrimaryKey(orderId);
if (ord == null || !ord.getCustomerid().equals(userId)) {
......@@ -487,17 +494,17 @@ public class OrderMainServiceImpl {
}
//积分金额
if(ord.getDactscore() == null){
if (ord.getDactscore() == null) {
return Result.error("订单参数错误");
}
//支付状态
if(!ord.getIpaystatus().equals(OrderMain.PAY_STATUS_NO)){
if (!ord.getIpaystatus().equals(OrderMain.PAY_STATUS_NO)) {
return Result.error("订单参数错误");
}
//订单状态
if(!ord.getIstatus().equals(OrderMain.STATUS_NOPAY)){
if (!ord.getIstatus().equals(OrderMain.STATUS_NOPAY)) {
return Result.error("订单参数错误");
}
......@@ -507,10 +514,10 @@ public class OrderMainServiceImpl {
inte.setCustomerid(ord.getCustomerid());
Double inteNum = this.integralrecDao.sumIntegral(inte);
if(inteNum == null || inteNum < 0) return Result.error("积分不足,无法支付");
if (inteNum == null || inteNum < 0) return Result.error("积分不足,无法支付");
// 用户收入积分减去支付积分要大于订单积分价格
if((inteNum!=null ? inteNum : 0) < ord.getDactscore()) {
if ((inteNum != null ? inteNum : 0) < ord.getDactscore()) {
return Result.error("积分不足,无法支付");
}
......@@ -524,7 +531,7 @@ public class OrderMainServiceImpl {
integralrec.setSoprdate(DateTools.getDate("yyyy-MM-dd"));
integralrec.setToprtime(new Date());
int res = integralrecDao.insert(integralrec);
if (res <= 0){
if (res <= 0) {
return Result.success("支付失败");
}
//改变订单状态
......@@ -560,22 +567,52 @@ public class OrderMainServiceImpl {
@Transactional(rollbackFor = Exception.class)
public Result refundOrder(OrderMain order, JSONArray ids) {
OrderMain orderMain = this.orderMainDao.selectById(order.getId());
orderMain.setSrefundreason(order.getSrefundreason());
orderMain.setSrefundpic(order.getSrefundpic());
orderMain.setIrefundstatus(order.getIrefundstatus());
// orderMain.setSrefundreason(order.getSrefundreason());
// orderMain.setSrefundpic(order.getSrefundpic());
// orderMain.setIrefundstatus(order.getIrefundstatus());
OrderRefund orderRefund = new OrderRefund();
Double refundmoney = Double.valueOf(0.0);
if (CollectionUtils.isNotEmpty(ids)) {
List<OrderSub> orderSubs = this.orderSubDao.selectList(Wrappers.<OrderSub>lambdaQuery().eq(OrderSub::getMainid, order.getId()).in(OrderSub::getId, ids));
for (OrderSub sub : orderSubs) {
List<JSONObject> objects = JSON.parseArray(ids.toJSONString(), JSONObject.class);
List<OrderSub> orderSubs = this.orderSubDao.selectList(Wrappers.<OrderSub>lambdaQuery().eq(OrderSub::getMainid, order.getId()));
for (JSONObject id : objects) {
int num = (int) id.get("num");
if (num == 0) {
throw new RuntimeException("退款数量不可以为0");
}
OrderSub sub = orderSubs.stream().filter(orderSub -> orderSub.getId().equals(id.get("id")) ).findAny().get();
if (ObjectUtils.isNotEmpty(sub)) {
if ((sub.getIpronum() - (sub.getSdef3() != null ? Integer.parseInt(sub.getSdef3()) : 0)) < num) {
return Result.error("退款数量不能大于购买数量");
}
if (sub.getIpronum() > num) {
orderRefund.setPortion("0");
} else {
orderRefund.setPortion("1");
}
sub.setSdef1("1");
refundmoney = refundmoney + sub.getDprosum();
sub.setSdef3(((sub.getSdef3() != null ? Integer.parseInt(sub.getSdef3()) : 0) + num) + "");
refundmoney = refundmoney + (sub.getSgoodprice() * num);
this.orderSubDao.updateById(sub);
}
}else {
}
if (orderSubs.size() > ids.size()) {
orderRefund.setPortion("0");
}
} else {
refundmoney = orderMain.getDactmoney();
}
orderMain.setIrefundmoney(refundmoney);
this.orderMainDao.updateById(orderMain);
orderRefund.setOrderMianId(Long.valueOf(orderMain.getId()));
orderRefund.setRefundDetail(ids.toJSONString());
orderRefund.setRefundMoney(refundmoney);
orderRefund.setRefundReason(order.getSrefundreason());
orderRefund.setRefundImg(order.getSrefundpic());
orderRefund.setRefundTime(new Date());
orderRefund.setRefundType(order.getIrefundstatus() == 106 ? "1" : "2");
orderRefund.setRefundStatus("1");
refundMapper.insert(orderRefund);
// orderMain.setIrefundmoney(refundmoney);
// this.orderMainDao.updateById(orderMain);
return Result.success("成功");
}
......@@ -593,6 +630,7 @@ public class OrderMainServiceImpl {
/**
* 仅退款
*
* @param order
* @return
*/
......
......@@ -2,11 +2,9 @@ package com.yunniu.farming.webadmin.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yunniu.farming.util.*;
import com.yunniu.farming.webadmin.dao.CustomerDao;
import com.yunniu.farming.webadmin.dao.GroupBuyDao;
import com.yunniu.farming.webadmin.dao.IntegralrecDao;
import com.yunniu.farming.webadmin.dao.OrderMainDao;
import com.yunniu.farming.webadmin.dao.*;
import com.yunniu.farming.webadmin.model.*;
import com.yunniu.farming.webadmin.service.WxService;
import com.yunniu.farming.wx.WxConfigUtil;
......@@ -49,6 +47,9 @@ public class WxServiceImpl implements WxService {
@Autowired
private GroupBuyDao groupBuyDao;
@Autowired
private OrderRefundMapper refundMapper;
private String[] imageUrl = {"https://yuezhi-1314984551.cos.ap-shanghai.myqcloud.com/register/41e98a7cc2834450b41927219197d713.jpeg"
, "https://yuezhi-1314984551.cos.ap-shanghai.myqcloud.com/register/65daa7ab2a9c46c99a580874c73465e3.jpeg"
, "https://yuezhi-1314984551.cos.ap-shanghai.myqcloud.com/register/056bb47d0b274ab7b430ddd522b18ee3.jpeg"
......@@ -243,9 +244,14 @@ public class WxServiceImpl implements WxService {
order.setSrefundreason(srefundreason); // 退款理由
order.setIrefundstatus(OrderMain.STATUS_CANCEL);
}
order.setTrefundtime(new Date());
order.setRefundorderno(StringHelper.getOrderno());
orderMainDao.updateById(order);
// order.setTrefundtime(new Date());
// order.setRefundorderno(StringHelper.getOrderno());
// orderMainDao.updateById(order);
OrderRefund refund = refundMapper.selectOne(Wrappers.<OrderRefund>lambdaQuery()
.eq(OrderRefund::getOrderMianId, order.getId())
.eq(OrderRefund::getRefundStatus, 6));
refund.setRefundCode(StringHelper.getOrderno());
refundMapper.updateById(refund);
double tradeMoney = order.getDactmoney();
DecimalFormat decimalFormat = new DecimalFormat("###################");
......@@ -257,15 +263,15 @@ public class WxServiceImpl implements WxService {
parameters.put("out_trade_no", order.getSorderno()); // 商户订单号
parameters.put("refund_fee_type", "CNY"); // 默认人民币:CNY
parameters.put("total_fee", decimalFormat.format(tradeMoney * 100)); // 订单总金额
if (order.getIrefundstatus().equals(OrderMain.STATUS_APPLICATION)) {
parameters.put("refund_fee", decimalFormat.format(order.getIrefundmoney() * 100)); // 订单总金额
if (refund.getRefundStatus().equals(1)) {
parameters.put("refund_fee", decimalFormat.format(refund.getRefundMoney() * 100)); // 订单总金额
}else {
parameters.put("refund_fee", decimalFormat.format(order.getIrefundmoney() * 100)); // 退款金额
parameters.put("refund_fee", decimalFormat.format(refund.getRefundMoney() * 100)); // 退款金额
}
//parameters.put("profit_sharing", "Y");
// 用户端实际ip
parameters.put("notify_url", WxConfigUtil.refund_notify_url); // 接收微信支付异步通知回调地址
parameters.put("out_refund_no", order.getRefundorderno());
parameters.put("out_refund_no", refund.getRefundCode());
System.out.println("sign=====" + parameters);
// 设置签名
String sign = WxUtil.createSignMD5(parameters);
......
......@@ -15,9 +15,9 @@ public class WxConfigUtil {
public final static String UNIFIED_ORDER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder";
public final static String PROFIT_SHARING_URL = "https://api.mch.weixin.qq.com/secapi/pay/profitsharing";
public final static String PROFIT_SHARING_ADDRECEIVER = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver";
// public final static String notify_url = "http://farming.nyinhong.com/wx/notify"; // 订单回调接口
// public final static String notify_url = "http://felo.nyinhong.com/wx/notify"; // 订单回调接口
public final static String notify_url = "https://qpxdnyy.com/wx/notify"; // 订单回调接口
// public final static String refund_notify_url = "http://farming.nyinhong.com/wx/wxRefundNotify"; // 订单回调接口
// public final static String refund_notify_url = "http://felo.nyinhong.com/wx/wxRefundNotify"; // 订单回调接口
public final static String refund_notify_url = "https://qpxdnyy.com/wx/wxRefundNotify"; // 订单回调接口
public final static String REFUND_ORDER_URL = "https://api.mch.weixin.qq.com/secapi/pay/refund";
public static String GET_MINICODE_URL = "https://api.weixin.qq.com/wxa/getwxacodeunlimit";
......
......@@ -3,6 +3,7 @@ package com.yunniu.farming.wx;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yunniu.farming.util.HttpClientUtil;
import org.apache.commons.codec.digest.DigestUtils;
import org.jdom.JDOMException;
import javax.crypto.Mac;
......@@ -102,8 +103,8 @@ public class WxUtil {
}
}
sb.append("key=" + WxConfigUtil.API_KEY);
String sign = MD5(sb.toString());
return sign;
String sign = DigestUtils.md5Hex(sb.toString());
return sign.toUpperCase();
}
......
......@@ -61,6 +61,7 @@
<!-- 以下为商品相关字段 -->
<result column="zsproductname" property="sproductname" jdbcType="VARCHAR"/>
<result column="zspshortpic" property="spshortpic" jdbcType="VARCHAR"/>
<result column="zsdef2" property="sdef2" jdbcType="VARCHAR"/>
</collection>
</resultMap>
......@@ -191,7 +192,7 @@
</select>
<resultMap id="ResultMap" type="com.yunniu.farming.webadmin.model.OrderMain">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="id" property="id" jdbcType="INTEGER"/>
<result column="customerid" property="customerid" jdbcType="INTEGER"/>
<result column="addressid" property="addressid" jdbcType="INTEGER"/>
<result column="sorderno" property="sorderno" jdbcType="VARCHAR"/>
......@@ -233,6 +234,17 @@
<result column="groupBuyId" property="groupBuyId" jdbcType="BIGINT"/>
<result column="groupBuyName" property="groupBuyName" jdbcType="VARCHAR"/>
<association property="customer" column="customerid" select="selectCustomer"/>
<collection property="orderRefund" javaType="com.yunniu.farming.webadmin.model.OrderRefund">
<result column="refund_type" jdbcType="CHAR" property="refundType" />
<result column="portion" jdbcType="CHAR" property="portion" />
<result column="refund_code" jdbcType="VARCHAR" property="refundCode" />
<result column="refund_status" jdbcType="CHAR" property="refundStatus" />
<result column="refund_money" jdbcType="DOUBLE" property="refundMoney" />
<result column="refund_time" jdbcType="TIMESTAMP" property="refundTime" />
<result column="refund_reason" jdbcType="VARCHAR" property="refundReason" />
<result column="refund_img" jdbcType="VARCHAR" property="refundImg" />
<result column="refund_detail" jdbcType="VARCHAR" property="refundDetail" />
</collection>
<!-- FRICE TODO 一对多 关联查询 -->
<collection property="subs" ofType="com.yunniu.farming.webadmin.model.OrderSub" select="selectOrderSub" column="id"/>
......@@ -265,10 +277,52 @@
<!-- 带参数分页查询 S -->
<select id="selectByParamPageList" resultMap="ResultMap"
parameterType="com.yunniu.farming.webadmin.model.OrderMain">
SELECT
<include refid="Full_Column_List"/>
SELECT ordermain.id
, customerid
, addressid
, sorderno
, sorderdate
, tordertime
, tovertime
, dplanmoney
, dactmoney
, dactscore
, ipaystatus
, tpaytime
, refundorderno
, irefundmoney
, trefundtime
, srefundreason
, srefundpic
, refund.couriernumber
, istatus
, itype
, group_order_id
, productid
, ipaytype
, shareuid
, sremark
, sdef1
, sdef2
, sdef3
, sdef4
, sdef5
, idef6
, idef7
, ddef8
, ddef9
, ddef10
, scusaddr
, scuname
, scuphone
, sprovince
, scity
, sregion
, refund.refund_status as irefundstatus
<!-- 关联子表信息 -->
FROM order_main ordermain
left join order_refund refund
on ordermain.id = refund.order_mian_id AND refund.id = (select MAX(id) from order_refund where order_mian_id = ordermain.id)
<where>
<if test="appflag == null or appflag == ''">
ordermain.itype = 10
......@@ -303,6 +357,7 @@
AND ordermain.sorderdate <![CDATA[ <= ]]> #{endDate,jdbcType=VARCHAR}
</if>
</where>
group by ordermain.id
<!-- 以时间倒序显示 -->
ORDER BY ordermain.tordertime DESC
</select>
......@@ -321,6 +376,7 @@
sub.sgoodprice AS zsgoodprice,
sub.sproductname AS zsproductname,
sub.spshortpic AS zspshortpic,
ifnull(sub.sdef2, 0) as zsdef2,
go.remark
FROM order_main ordermain
LEFT JOIN order_sub sub ON ordermain.id = sub.mainid
......@@ -410,18 +466,119 @@
order by tordertime desc limit 1
</select>
<select id="selectByParamPageRefundGroupList" resultMap="ResultMap">
<resultMap id="RefundResultMap" type="com.yunniu.farming.webadmin.model.OrderMain">
<id column="zid" property="zid" jdbcType="INTEGER"/>
<result column="id" property="id" jdbcType="INTEGER"/>
<result column="customerid" property="customerid" jdbcType="INTEGER"/>
<result column="addressid" property="addressid" jdbcType="INTEGER"/>
<result column="sorderno" property="sorderno" jdbcType="VARCHAR"/>
<result column="scusaddr" property="scusaddr" jdbcType="VARCHAR"/>
<result column="scuname" property="scuname" jdbcType="VARCHAR"/>
<result column="scuphone" property="scuphone" jdbcType="VARCHAR"/>
<result column="sprovince" property="sprovince" jdbcType="VARCHAR"/>
<result column="scity" property="scity" jdbcType="VARCHAR"/>
<result column="sregion" property="sregion" jdbcType="VARCHAR"/>
<result column="sorderdate" property="sorderdate" jdbcType="CHAR"/>
<result column="tordertime" property="tordertime" jdbcType="TIMESTAMP"/>
<result column="tovertime" property="tovertime" jdbcType="TIMESTAMP"/>
<result column="dplanmoney" property="dplanmoney" jdbcType="DECIMAL"/>
<result column="dactmoney" property="dactmoney" jdbcType="DECIMAL"/>
<result column="dactscore" property="dactscore" jdbcType="DECIMAL"/>
<result column="ipaystatus" property="ipaystatus" jdbcType="INTEGER"/>
<result column="group_order_id" property="groupOrderId" jdbcType="INTEGER"/>
<result column="irefundstatus" property="irefundstatus" jdbcType="INTEGER"/>
<result column="irefundmoney" property="irefundmoney" jdbcType="INTEGER"/>
<result column="tpaytime" property="tpaytime" jdbcType="TIMESTAMP"/>
<result column="trefundtime" property="trefundtime" jdbcType="TIMESTAMP"/>
<result column="istatus" property="istatus" jdbcType="INTEGER"/>
<result column="itype" property="itype" jdbcType="INTEGER"/>
<result column="srefundreason" property="srefundreason" jdbcType="VARCHAR"/>
<result column="srefundpic" property="srefundpic" jdbcType="VARCHAR"/>
<result column="couriernumber" property="couriernumber" jdbcType="VARCHAR"/>
<result column="productid" property="productid" jdbcType="INTEGER"/>
<result column="ipaytype" property="ipaytype" jdbcType="INTEGER"/>
<result column="sremark" property="sremark" jdbcType="VARCHAR"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="sdef1" property="sdef1" jdbcType="VARCHAR"/>
<result column="sdef2" property="sdef2" jdbcType="VARCHAR"/>
<result column="sdef3" property="sdef3" jdbcType="VARCHAR"/>
<result column="sdef4" property="sdef4" jdbcType="VARCHAR"/>
<result column="sdef5" property="sdef5" jdbcType="VARCHAR"/>
<result column="idef6" property="idef6" jdbcType="INTEGER"/>
<result column="idef7" property="idef7" jdbcType="INTEGER"/>
<result column="ddef8" property="ddef8" jdbcType="DECIMAL"/>
<result column="ddef9" property="ddef9" jdbcType="DECIMAL"/>
<result column="ddef10" property="ddef10" jdbcType="TIMESTAMP"/>
<result column="groupBuyId" property="groupBuyId" jdbcType="BIGINT"/>
<result column="groupBuyName" property="groupBuyName" jdbcType="VARCHAR"/>
<association property="customer" column="customerid" select="selectCustomer"/>
<association property="orderRefund" javaType="com.yunniu.farming.webadmin.model.OrderRefund">
<result column="refund_type" jdbcType="CHAR" property="refundType" />
<result column="portion" jdbcType="CHAR" property="portion" />
<result column="refund_code" jdbcType="VARCHAR" property="refundCode" />
<result column="refund_status" jdbcType="CHAR" property="refundStatus" />
<result column="refund_money" jdbcType="DOUBLE" property="refundMoney" />
<result column="refund_time" jdbcType="TIMESTAMP" property="refundTime" />
<result column="refund_reason" jdbcType="VARCHAR" property="refundReason" />
<result column="refund_img" jdbcType="VARCHAR" property="refundImg" />
<result column="refund_detail" jdbcType="VARCHAR" property="refundDetail" />
</association>
</resultMap>
<select id="selectByParamPageRefundGroupList" resultMap="RefundResultMap">
SELECT
<include refid="Full_Column_List"/>
<!-- 关联子表信息 -->
,gb.id as groupBuyId
,gb.group_buy_title as groupBuyName
FROM order_main ordermain
left join group_order go on ordermain.group_order_id = go.id
left join group_buy gb on go.group_buy_id = gb.id
ordermain.id,
ordermain.customerid,
ordermain.addressid,
ordermain.sorderno,
ordermain.sorderdate,
ordermain.tordertime,
ordermain.tovertime,
ordermain.dplanmoney,
ordermain.dactmoney,
ordermain.dactscore,
ordermain.ipaystatus,
ordermain.tpaytime,
ordermain.couriernumber,
ordermain.istatus,
ordermain.itype,
ordermain.group_order_id,
ordermain.productid,
ordermain.ipaytype,
ordermain.shareuid,
ordermain.sremark,
ordermain.sdef1,
ordermain.sdef2,
ordermain.sdef3,
ordermain.ddef8,
ordermain.scusaddr,
ordermain.scuname,
ordermain.scuphone,
ordermain.sprovince,
ordermain.scity,
ordermain.sregion,
orderRefund.id as zid,
orderRefund.refund_type,
orderRefund.portion,
orderRefund.refund_code,
orderRefund.refund_status,
orderRefund.refund_money,
orderRefund.refund_time,
orderRefund.refund_suc_time,
orderRefund.refund_reason,
orderRefund.refund_img,
orderRefund.refund_detail,
gb.id AS groupBuyId,
gb.group_buy_title AS groupBuyName
FROM
order_refund AS orderRefund
LEFT JOIN order_main AS ordermain ON orderRefund.order_mian_id = ordermain.id
LEFT JOIN group_order go ON ordermain.group_order_id = go.id
LEFT JOIN group_buy gb ON go.group_buy_id = gb.id
<where>
ordermain.group_order_id IS NOT NULL
AND ordermain.irefundstatus IS NOT NULL
and orderRefund.order_mian_id is not null
<if test="id != null">
AND ordermain.id = #{id,jdbcType=INTEGER}
</if>
......@@ -453,6 +610,6 @@
</if>
</where>
<!-- 以时间倒序显示 -->
ORDER BY ordermain.tordertime DESC
ORDER BY orderRefund.refund_time DESC
</select>
</mapper>
......@@ -83,12 +83,12 @@
<script type="text/html" id="table-handle">
<i class="layui-icon layui-icon-form" lay-event="orderDetail" title="订单详情"></i>
<!-- 101退款申请中 102待退货 103待退款 104退款成功 105退款拒绝-->
{{#if (d.irefundstatus == 101) { }}
{{#if (d.orderRefund.refundStatus == 1 && d.orderRefund.refundType == 1) { }}
<i class="layui-icon layui-icon-ok" lay-event="pass" title="退款申请通过"></i>
<i class="layui-icon layui-icon-close" lay-event="refuse" title="退款申请拒绝"></i>
{{# }else if(d.irefundstatus == 103){ }}
{{# }else if(d.orderRefund.refundStatus == 4){ }}
<i class="layui-icon layui-icon-component" lay-event="receive" title="退款已收货"></i>
{{# }else if(d.irefundstatus == 106){ }}
{{# }else if(d.orderRefund.refundStatus == 1 && d.orderRefund.refundType == 2){ }}
<i class="layui-icon layui-icon-ok" lay-event="pass" title="仅退款申请通过"></i>
<i class="layui-icon layui-icon-close" lay-event="refuse" title="仅退款申请拒绝"></i>
{{# } }}
......@@ -165,27 +165,28 @@
str += "<span style=''>" + d.customer.swxnick ? d.customer.swxnick : '' + "</span>"
}
}
return str;
}
}
,{
title: "订单金额",
width: 150,
templet: function(d) {
var str = "";
str += '金额:<span style="color:red;"> '+(d.dactmoney ? d.dactmoney : 0)+ '</span>&nbsp';
str += '积分:<span style="color:red;"> '+(d.dactscore ? d.dactscore : 0)+ '</span>';
str += '</div>';
return str ? str : "";
}
}
, {field: 'irefundmoney', width: 150, title: '退款金额'}
, {width: 150, title: '退款金额',
templet: function(d) {
var str = "";
str += '<span> '+(d.orderRefund.refundMoney ? d.orderRefund.refundMoney : 0)+ '</span>&nbsp';
str += '</div>';
return str ? str : "";
}
}
,{
title: "订单状态",
width: 200,
......@@ -209,12 +210,12 @@
str += ' <span>' + status + '</span>';
// 101退款申请中 102待退货 103待退款 104退款成功
var refundStatus = "";
if (d.irefundstatus == 101) refundStatus = "<span class='layui-badge layui-bg-red'>退款申请</span>";
if (d.irefundstatus == 102) refundStatus = "<span class='layui-badge layui-bg-orange'>待退货</span>";
if (d.irefundstatus == 103) refundStatus = "<span class='layui-badge layui-bg-orange'>待退款</span>";
if (d.irefundstatus == 104) refundStatus = "<span class='layui-badge layui-bg-green'>退款成功</span>";
if (d.irefundstatus == 105) refundStatus = "<span class='layui-badge layui-bg-cyan'>退款拒绝</span>";
if (d.irefundstatus == 106) refundStatus = "<span class='layui-badge layui-bg-red'>仅退款申请</span>";
if (d.orderRefund.refundStatus == 1 && d.orderRefund.refundType == 1) refundStatus = "<span class='layui-badge layui-bg-red'>退款申请</span>";
if (d.orderRefund.refundStatus == 4) refundStatus = "<span class='layui-badge layui-bg-orange'>待退货</span>";
if (d.orderRefund.refundStatus == 6) refundStatus = "<span class='layui-badge layui-bg-orange'>待退款</span>";
if (d.orderRefund.refundStatus == 5) refundStatus = "<span class='layui-badge layui-bg-green'>退款成功</span>";
if (d.orderRefund.refundStatus == 3) refundStatus = "<span class='layui-badge layui-bg-cyan'>退款拒绝</span>";
if (d.orderRefund.refundStatus == 1 && d.orderRefund.refundType == 2) refundStatus = "<span class='layui-badge layui-bg-red'>仅退款申请</span>";
str += ' <span>' + refundStatus + '</span>';
str += '</div>';
return str ? str : "";
......@@ -222,18 +223,32 @@
}
, {field: 'tordertime', width: 100, title: '下单日期'}
, {field: 'sremark', width: 100,title: '备注'}
, {field: 'trefundtime', width: 100, title: '退款时间'}
, {width: 100, title: '退款时间',
templet: function(d) {
var str = "";
str += '<span> '+(d.orderRefund.refundSucTime ? d.orderRefund.refundSucTime : "")+ '</span>&nbsp';
str += '</div>';
return str ? str : "";
}
}
,{
width: 100,
title: "退款图片",
align: "center",
templet: function(d) {
return d.srefundpic ? '<div><img id="zi' + d.id + '" src="' + d.srefundpic +
return d.orderRefund.refundImg ? '<div><img id="zi' + d.id + '" src="' + d.orderRefund.refundImg +
'" onmouseover="bigImg(this)" onmouseout="smallImg()" onclick="tolook(src)" style="height:20px;"></div>' :
'';
}
}
, {field: 'srefundreason', width: 100, title: '退款理由'}
, {width: 100, title: '退款理由',
templet: function(d) {
var str = "";
str += '<span> '+(d.orderRefund.refundReason ? d.orderRefund.refundReason : "")+ '</span>&nbsp';
str += '</div>';
return str ? str : "";
}
}
, {field: 'couriernumber', width: 120, title: '退款快递单号'}
, {field: 'scusaddr', width: 100, title: '地址'}
, {field: 'scuname', width: 100, title: '联系姓名'}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment