Commit 3de7e35e by sdif

用户端代码提交

parent 6fd35e64
...@@ -103,4 +103,15 @@ public class UserRefundController extends BaseController { ...@@ -103,4 +103,15 @@ public class UserRefundController extends BaseController {
@PathVariable Integer[] ids) { @PathVariable Integer[] ids) {
return toAjax(iUserRefundService.deleteWithValidByIds(Arrays.asList(ids), true)); return toAjax(iUserRefundService.deleteWithValidByIds(Arrays.asList(ids), true));
} }
/**
* pc审核退款
*/
@SaCheckPermission("system:userRefund:refund")
@Log(title = "用户退款", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping("/refund")
public R<Void> refund(@Validated(EditGroup.class) @RequestBody UserRefundBo bo) {
return toAjax(iUserRefundService.refund(bo));
}
} }
...@@ -242,10 +242,12 @@ public class EmployeesServiceImpl implements IEmployeesService { ...@@ -242,10 +242,12 @@ public class EmployeesServiceImpl implements IEmployeesService {
.eq(TotalOrder::getEmId, employeesVo.getId()) .eq(TotalOrder::getEmId, employeesVo.getId())
.eq(TotalOrder::getIsSatisfaction, 1) .eq(TotalOrder::getIsSatisfaction, 1)
.orderByDesc(TotalOrder::getId)); .orderByDesc(TotalOrder::getId));
for (TotalOrderVo order : totalOrder) { if(null != totalOrder && totalOrder.size() != 0){
BusinessVo businessVo = businessMapper.selectVoOne(new LambdaQueryWrapper<Business>().eq(Business::getId, order.getBusinessId())); for (TotalOrderVo order : totalOrder) {
if (null != businessVo) { BusinessVo businessVo = businessMapper.selectVoOne(new LambdaQueryWrapper<Business>().eq(Business::getId, order.getBusinessId()));
order.setProject(businessVo.getName()); if (null != businessVo) {
order.setProject(businessVo.getName());
}
} }
} }
employeesVo.setTotalOrderVo(totalOrder); employeesVo.setTotalOrderVo(totalOrder);
......
...@@ -107,4 +107,14 @@ public class TotalOrderBo extends BaseEntity { ...@@ -107,4 +107,14 @@ public class TotalOrderBo extends BaseEntity {
* 凭证 * 凭证
*/ */
private String voucher; private String voucher;
/**
* 是否后台退款
*/
private Integer isPcRefund;
/**
* pc是否同意退款1-完成退款,2-取消退款
*/
private Integer isPcRefundStatus;
} }
...@@ -46,4 +46,9 @@ public interface IUserRefundService { ...@@ -46,4 +46,9 @@ public interface IUserRefundService {
* 校验并批量删除用户退款信息 * 校验并批量删除用户退款信息
*/ */
Boolean deleteWithValidByIds(Collection<Integer> ids, Boolean isValid); Boolean deleteWithValidByIds(Collection<Integer> ids, Boolean isValid);
/**
* 后台审核退款
*/
Boolean refund(UserRefundBo bo);
} }
...@@ -371,7 +371,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -371,7 +371,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
List<StoreGoodsTag> storeGoodsTags = storeGoodsTagMapper.selectList(new LambdaQueryWrapper<StoreGoodsTag>().in(StoreGoodsTag::getId, ids).select(StoreGoodsTag::getTitle)); List<StoreGoodsTag> storeGoodsTags = storeGoodsTagMapper.selectList(new LambdaQueryWrapper<StoreGoodsTag>().in(StoreGoodsTag::getId, ids).select(StoreGoodsTag::getTitle));
totalOrderVo.setTags(storeGoodsTags); totalOrderVo.setTags(storeGoodsTags);
totalOrderVo.setPrice(storeGoods.getPrice()); totalOrderVo.setPrice(storeGoods.getPrice());
totalOrderVo.setCover(storeGoods.getSmallCover());
totalOrderVo.setName(storeGoods.getTitle()); totalOrderVo.setName(storeGoods.getTitle());
} }
}); });
...@@ -513,7 +513,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -513,7 +513,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
storeOrder.setStoreId(storeGoods1.getStoreId()); storeOrder.setStoreId(storeGoods1.getStoreId());
// 扣除库存 // 扣除库存
storeGoods1.setId(storeOrder.getId()); storeGoods1.setId(storeOrder.getGoodsId());
storeGoods1.setInventory(storeGoods1.getInventory() - storeOrder.getNum()); storeGoods1.setInventory(storeGoods1.getInventory() - storeOrder.getNum());
storeGoods1.setSaleNum(storeGoods1.getSaleNum() + 1); storeGoods1.setSaleNum(storeGoods1.getSaleNum() + 1);
storeGoodsMapper.updateById(storeGoods1); storeGoodsMapper.updateById(storeGoods1);
...@@ -631,9 +631,11 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -631,9 +631,11 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
double fenmo = (double) services.getFenmo() / 100; double fenmo = (double) services.getFenmo() / 100;
double v = totalOrder1.getPayMoney() * fenmo; double v = totalOrder1.getPayMoney() * fenmo;
employeesDivide.setProportion(services.getFenmo()); employeesDivide.setProportion(services.getFenmo());
employeesDivide.setEmId(employees.getId()); employeesDivide.setEmId(employees.getId());
money = v;
money = totalOrder1.getPayMoney() - v;;
if (employees.getCompanyId() != 0) { if (employees.getCompanyId() != 0) {
...@@ -651,11 +653,19 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -651,11 +653,19 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
employeesMapper.updateById(employees); employeesMapper.updateById(employees);
employeesDivide.setDividePrice(money + ""); employeesDivide.setDividePrice(money + "");
} }
employeesDivideMapper.insert(employeesDivide); employeesDivideMapper.insert(employeesDivide);
} }
if(totalOrder1.getBusinessId() == 0){
ISonOrderService orderService = serviceBuilder.getSonOrderService(totalOrder1.getBusinessId());
// 修改子订单状态
orderService.switchSonOrderStatus(totalOrder1.getId(), CommonOrderStatus.DONE.getCode());
}
} }
return baseMapper.updateById(totalOrder) > 0; return baseMapper.updateById(totalOrder) > 0;
...@@ -742,7 +752,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -742,7 +752,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
double v = totalOrder.getPayMoney() * fenmo; double v = totalOrder.getPayMoney() * fenmo;
money = v; money = totalOrder.getPayMoney() - v;
if (employees.getCompanyId() != 0) { if (employees.getCompanyId() != 0) {
...@@ -793,10 +803,40 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -793,10 +803,40 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
if (null == sonOrderSimpleDataByTotalId) { if (null == sonOrderSimpleDataByTotalId) {
throw new ServiceException("子订单状态出错!"); throw new ServiceException("子订单状态出错!");
} }
int IsRefund = getIsRefund(totalOrder.getBusinessId(), totalOrder.getStatus(), sonOrderSimpleDataByTotalId.getSonOrderId()); int IsRefund = getIsRefund(totalOrder.getBusinessId(), totalOrder.getStatus(), sonOrderSimpleDataByTotalId.getOrderStatus());
// 订单退款金额 // 订单退款金额
double money = 0; double money = 0;
if (null != bo.getIsPcRefund() && bo.getIsPcRefund() == 1){
money = totalOrder.getRefundAmount();
//pc是否同意退款1-完成退款,2-取消退款
if(bo.getIsPcRefundStatus() == 1 ){
WxPayRefundRequest request = new WxPayRefundRequest();
request.setOutTradeNo(totalOrder.getOrderSn());
request.setOutRefundNo(UUID.randomUUID().toString());
request.setTotalFee((int) (totalOrder.getPayMoney() * 100));
request.setRefundFee((int) (money * 100));
request.setNotifyUrl("https://peizheng.shanpeikj.com/api/applet/totalOrder/orderRefundCallBack");
try {
iPayService.refund(request);
return true;
} catch (WxPayException e) {
e.printStackTrace();
return false;
}
}else if(bo.getIsPcRefundStatus() == 2){
//后台取消直接将订单完成
totalOrder.setStatus(TotalOrderStatus.DONE.getCode());
baseMapper.updateById(totalOrder);
return orderService.switchSonOrderStatus(totalOrder.getId(), CommonOrderStatus.DONE.getCode());
}
}
if (IsRefund == 0) {// 陪诊员订单未完成用户主动退款直接退到账户 if (IsRefund == 0) {// 陪诊员订单未完成用户主动退款直接退到账户
// 主订单必须为付款并且子订单为已接单 // 主订单必须为付款并且子订单为已接单
if (totalOrder.getStatus() != 1 && sonOrderSimpleDataByTotalId.getOrderStatus() != 1) { if (totalOrder.getStatus() != 1 && sonOrderSimpleDataByTotalId.getOrderStatus() != 1) {
...@@ -1169,14 +1209,14 @@ public class TotalOrderServiceImpl implements ITotalOrderService { ...@@ -1169,14 +1209,14 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
long hour = getHour(serveTime); long hour = getHour(serveTime);
if (hour >= 12 || (hour <= 12 && hour > 6)) { if (hour > 6) {
money = payMoney; money = payMoney;
} else if ((hour <= 6) && (hour >= 3)) { } else if (hour >= 3) {
// 计算扣除30%后的金额 // 计算扣除30%后的金额
deduction = payMoney * 0.3; deduction = payMoney * 0.3;
remainingAmount = payMoney - deduction; remainingAmount = payMoney - deduction;
money = remainingAmount; money = remainingAmount;
} else if ((hour <= 3) && (hour >= 0)) { } else if (hour >= 0) {
// 计算扣除50%后的金额 // 计算扣除50%后的金额
deduction = payMoney * 0.5; deduction = payMoney * 0.5;
remainingAmount = payMoney - deduction; remainingAmount = payMoney - deduction;
......
...@@ -7,8 +7,11 @@ import com.pz.common.core.domain.PageQuery; ...@@ -7,8 +7,11 @@ import com.pz.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.pz.common.exception.ServiceException;
import com.pz.system.domain.bo.TotalOrderBo;
import com.pz.system.mapper.BusinessMapper; import com.pz.system.mapper.BusinessMapper;
import com.pz.system.mapper.TotalOrderMapper; import com.pz.system.mapper.TotalOrderMapper;
import com.pz.system.service.ITotalOrderService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.pz.system.domain.bo.UserRefundBo; import com.pz.system.domain.bo.UserRefundBo;
...@@ -39,6 +42,8 @@ public class UserRefundServiceImpl implements IUserRefundService { ...@@ -39,6 +42,8 @@ public class UserRefundServiceImpl implements IUserRefundService {
private final BusinessMapper businessMapper; private final BusinessMapper businessMapper;
private final ITotalOrderService iTotalOrderServicer;
/** /**
* 查询用户退款 * 查询用户退款
*/ */
...@@ -136,4 +141,26 @@ public class UserRefundServiceImpl implements IUserRefundService { ...@@ -136,4 +141,26 @@ public class UserRefundServiceImpl implements IUserRefundService {
} }
return baseMapper.deleteBatchIds(ids) > 0; return baseMapper.deleteBatchIds(ids) > 0;
} }
@Override
public Boolean refund(UserRefundBo bo) {
UserRefundVo userRefundVo = baseMapper.selectVoById(bo);
if(userRefundVo.getStatus() != 0){
throw new ServiceException("已处理!");
}
TotalOrderBo totalOrderBo = new TotalOrderBo();
totalOrderBo.setId(userRefundVo.getOrderId().longValue());
totalOrderBo.setIsPcRefund(1);
totalOrderBo.setIsPcRefundStatus(bo.getStatus());
Boolean aBoolean = iTotalOrderServicer.refundOrder(totalOrderBo);
if(aBoolean){
UserRefund refund = new UserRefund();
refund.setId(bo.getId());
refund.setStatus(bo.getStatus());
int i = baseMapper.updateById(refund);
return i > 0;
}
return false;
}
} }
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
</select> </select>
<select id="selectFinishTime" resultType="java.lang.String"> <select id="selectFinishTime" resultType="java.lang.String">
select start_day select concat(zyph_order.start_day, '-', zyph_order.start_time)
from total_order t left join zyph_order d on d.order_id = t.id from total_order t left join zyph_order d on d.order_id = t.id
where t.id = #{id} where t.id = #{id}
</select> </select>
......
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