Commit b1813513 by 邹磊浩

Merge remote-tracking branch 'origin/dev' into dev

parents ea3b6cd9 d9482df8
......@@ -54,8 +54,8 @@ public class AccompanyController extends BaseController {
* @return 未分配陪诊员的业务订单
*/
@GetMapping("/demands")
public TableDataInfo<AccompanyDemandVo> demandSquareList(PageQuery page) {
return totalOrderService.queryUndistributedOrder(page);
public TableDataInfo<AccompanyDemandVo> demandSquareList(@RequestHeader("city_id") Integer cityCode, PageQuery page) {
return totalOrderService.queryUndistributedOrder(cityCode, page);
}
/**
......@@ -66,7 +66,7 @@ public class AccompanyController extends BaseController {
*/
@GetMapping("/orderComment")
public TableDataInfo<AccompanyDemandVo> orderCommentList(@NotNull(message = "陪诊员ID不能为空") Integer emId, PageQuery page) {
return totalOrderService.queryOrderComment(emId,page);
return totalOrderService.queryOrderComment(emId, page);
}
/**
......
......@@ -103,4 +103,15 @@ public class UserRefundController extends BaseController {
@PathVariable Integer[] ids) {
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));
}
}
......@@ -92,7 +92,7 @@ public class CompanyController extends BaseController {
*/
@PutMapping("/withdraw")
public R<Boolean> withdrawDeposit(@RequestBody @Validated(EditGroup.class) WithdrawDepositBo bo) {
if (bo.getAmount().compareTo(BigDecimal.ZERO) != 0) {
if (bo.getAmount().compareTo(BigDecimal.ZERO) < 1) {
return R.fail("提现金额必须大于0");
}
if (bo.getIsMerchant()) {
......
......@@ -238,17 +238,21 @@ public class EmployeesServiceImpl implements IEmployeesService {
@Override
public EmployeesVo queryByApp(Integer id) {
EmployeesVo employeesVo = baseMapper.selectEmployeesById(id);
List<TotalOrderVo> totalOrder = totalOrderMapper.selectVoList(Wrappers.<TotalOrder>lambdaQuery()
.eq(TotalOrder::getEmId, employeesVo.getId())
.eq(TotalOrder::getIsSatisfaction, 1)
.orderByDesc(TotalOrder::getId));
for (TotalOrderVo order : totalOrder) {
BusinessVo businessVo = businessMapper.selectVoOne(new LambdaQueryWrapper<Business>().eq(Business::getId, order.getBusinessId()));
if (null != businessVo) {
order.setProject(businessVo.getName());
if(null != employeesVo){
List<TotalOrderVo> totalOrder = totalOrderMapper.selectVoList(Wrappers.<TotalOrder>lambdaQuery()
.eq(TotalOrder::getEmId, employeesVo.getId())
.eq(TotalOrder::getIsSatisfaction, 1)
.orderByDesc(TotalOrder::getId));
if(null != totalOrder && totalOrder.size() != 0){
for (TotalOrderVo order : totalOrder) {
BusinessVo businessVo = businessMapper.selectVoOne(new LambdaQueryWrapper<Business>().eq(Business::getId, order.getBusinessId()));
if (null != businessVo) {
order.setProject(businessVo.getName());
}
}
}
employeesVo.setTotalOrderVo(totalOrder);
}
employeesVo.setTotalOrderVo(totalOrder);
return employeesVo;
}
......
......@@ -107,4 +107,14 @@ public class TotalOrderBo extends BaseEntity {
* 凭证
*/
private String voucher;
/**
* 是否后台退款
*/
private Integer isPcRefund;
/**
* pc是否同意退款1-完成退款,2-取消退款
*/
private Integer isPcRefundStatus;
}
......@@ -113,7 +113,7 @@ public interface ITotalOrderService {
*
* @return 待分配陪诊员订单
*/
TableDataInfo<AccompanyDemandVo> queryUndistributedOrder(PageQuery page);
TableDataInfo<AccompanyDemandVo> queryUndistributedOrder(Integer cityCode, PageQuery page);
/**
* 陪诊员端 评价
......
......@@ -46,4 +46,9 @@ public interface IUserRefundService {
* 校验并批量删除用户退款信息
*/
Boolean deleteWithValidByIds(Collection<Integer> ids, Boolean isValid);
/**
* 后台审核退款
*/
Boolean refund(UserRefundBo bo);
}
......@@ -371,7 +371,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
List<StoreGoodsTag> storeGoodsTags = storeGoodsTagMapper.selectList(new LambdaQueryWrapper<StoreGoodsTag>().in(StoreGoodsTag::getId, ids).select(StoreGoodsTag::getTitle));
totalOrderVo.setTags(storeGoodsTags);
totalOrderVo.setPrice(storeGoods.getPrice());
totalOrderVo.setCover(storeGoods.getSmallCover());
totalOrderVo.setName(storeGoods.getTitle());
}
});
......@@ -513,7 +513,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
storeOrder.setStoreId(storeGoods1.getStoreId());
// 扣除库存
storeGoods1.setId(storeOrder.getId());
storeGoods1.setId(storeOrder.getGoodsId());
storeGoods1.setInventory(storeGoods1.getInventory() - storeOrder.getNum());
storeGoods1.setSaleNum(storeGoods1.getSaleNum() + 1);
storeGoodsMapper.updateById(storeGoods1);
......@@ -587,7 +587,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
return this.refundOrder(totalOrderBo);
}
//用户未付款 陪诊员为接单 和 用户未付款陪诊员已接单直接取消
// 用户未付款 陪诊员为接单 和 用户未付款陪诊员已接单直接取消
if ((sonOrderSimpleDataByTotalId.getOrderStatus() == 0 && totalOrder.getStatus() == 0) || (sonOrderSimpleDataByTotalId.getOrderStatus() == 1 && totalOrder.getStatus() == 0)) {
// yypzOrderMapper.selectOne(new LambdaQueryWrapper<YypzOrder>().eq(YypzOrder::getOrderId,totalOrder));
totalOrder.setStatus(TotalOrderStatus.CANCEL.getCode());
......@@ -631,9 +631,11 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
double fenmo = (double) services.getFenmo() / 100;
double v = totalOrder1.getPayMoney() * fenmo;
employeesDivide.setProportion(services.getFenmo());
employeesDivide.setEmId(employees.getId());
money = v;
money = totalOrder1.getPayMoney() - v;;
if (employees.getCompanyId() != 0) {
......@@ -651,11 +653,19 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
employeesMapper.updateById(employees);
employeesDivide.setDividePrice(money + "");
}
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;
......@@ -728,7 +738,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
// 修改子订单状态
boolean sonOrderFlag = orderService.switchSonOrderStatus(totalOrder.getId(), CommonOrderStatus.REFUND.getCode());
//除了商城订单和诊前挂号不需要给陪诊员和商户分成
// 除了商城订单和诊前挂号不需要给陪诊员和商户分成
if (totalOrder.getBusinessId() != 0 && totalOrder.getBusinessId() != 6 && totalOrder.getStatus() == 2) {
Services services = servicesMapper.selectById(totalOrder.getServiceId());
if (services.getFenmo() != 0) {
......@@ -742,7 +752,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
double v = totalOrder.getPayMoney() * fenmo;
money = v;
money = totalOrder.getPayMoney() - v;
if (employees.getCompanyId() != 0) {
......@@ -793,10 +803,40 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
if (null == sonOrderSimpleDataByTotalId) {
throw new ServiceException("子订单状态出错!");
}
int IsRefund = getIsRefund(totalOrder.getBusinessId(), totalOrder.getStatus(), sonOrderSimpleDataByTotalId.getSonOrderId());
int IsRefund = getIsRefund(totalOrder.getBusinessId(), totalOrder.getStatus(), sonOrderSimpleDataByTotalId.getOrderStatus());
// 订单退款金额
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 (totalOrder.getStatus() != 1 && sonOrderSimpleDataByTotalId.getOrderStatus() != 1) {
......@@ -911,12 +951,13 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
* @return 待分配陪诊员订单
*/
@Override
public TableDataInfo<AccompanyDemandVo> queryUndistributedOrder(PageQuery page) {
public TableDataInfo<AccompanyDemandVo> queryUndistributedOrder(Integer cityCode, PageQuery page) {
QueryWrapper<TotalOrder> wrapper = Wrappers.query();
// 筛选未分配订单
wrapper.apply("total_order.em_id = 0") // 未分配陪诊员订单
.in("total_order.status", 0, 1) // 待支付、已支付
.between("total_order.business_id", 1, 5)
.eq(cityCode != null, "total_order.city_id", cityCode) // 筛选城市
.orderByDesc("total_order.id");
IPage<AccompanyDemandVo> result = baseMapper.selectUndistributedTotalOrder(page.build(), wrapper);
// 装载子订单信息
......@@ -1168,14 +1209,14 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
long hour = getHour(serveTime);
if (hour >= 12 || (hour <= 12 && hour > 6)) {
if (hour > 6) {
money = payMoney;
} else if ((hour <= 6) && (hour >= 3)) {
} else if (hour >= 3) {
// 计算扣除30%后的金额
deduction = payMoney * 0.3;
remainingAmount = payMoney - deduction;
money = remainingAmount;
} else if ((hour <= 3) && (hour >= 0)) {
} else if (hour >= 0) {
// 计算扣除50%后的金额
deduction = payMoney * 0.5;
remainingAmount = payMoney - deduction;
......
......@@ -7,8 +7,11 @@ import com.pz.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.TotalOrderMapper;
import com.pz.system.service.ITotalOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.pz.system.domain.bo.UserRefundBo;
......@@ -39,6 +42,8 @@ public class UserRefundServiceImpl implements IUserRefundService {
private final BusinessMapper businessMapper;
private final ITotalOrderService iTotalOrderServicer;
/**
* 查询用户退款
*/
......@@ -135,4 +140,26 @@ public class UserRefundServiceImpl implements IUserRefundService {
}
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;
}
}
......@@ -75,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join total_order o on o.em_id = e.id
left join company c on c.id = e.company_id
left join sys_user s on s.user_id = e.uid
WHERE e.`status` = 1 and e.now_type= 1 and e.del_flag= 0
WHERE e.`status` = 1 and e.del_flag= 0
<if test="bo.companyId > 0">
and e.company_id = #{bo.companyId}
</if>
......@@ -102,20 +102,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectEmployeesById" resultType="com.pz.merchant.domain.vo.EmployeesVo">
SELECT e.id,
s.avatar,
e.start_year,
e.working_hours,
e.name,
e.working_hours,
ifnull(round((sum(if(o.is_satisfaction = 1, 1, 0)) / count(o.id)) * 100, 2), 0) AS satisfaction_rate
FROM employees e
INNER join total_order o on o.em_id = e.id
left join total_order o on o.em_id = e.id
left join company c on c.id = e.company_id
left join sys_user s on s.user_id = e.uid
WHERE e.`status` = 1
and e.now_type = 1
and e.del_flag = 0
and e.id = #{id}
GROUP BY e.id,
e.`name`
HAVING satisfaction_rate >= #{favorableRate};
</select>
<select id="selectOrder" resultType="com.pz.merchant.domain.vo.OrderInfoVO">
......
......@@ -105,7 +105,7 @@
</select>
<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
where t.id = #{id}
</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