Commit b1d8208d by sdif

用户端代码提交

parent 794320e1
......@@ -67,15 +67,15 @@ public class Company extends BaseEntity {
/**
* 总收益
*/
private String totalRevenue;
private double totalRevenue;
/**
* 当前余额
*/
private String balance;
private double balance;
/**
* 冻结余额
*/
private String freezeBalance;
private double freezeBalance;
/**
* 删除标志(0代表存在 2代表删除)
*/
......
......@@ -79,15 +79,15 @@ public class Employees extends BaseEntity {
/**
* 总收益
*/
private String totalRevenue;
private double totalRevenue;
/**
* 当前余额
*/
private String balance;
private double balance;
/**
* 冻结余额
*/
private String freezeBalance;
private double freezeBalance;
/**
* 取消订单次数
*/
......
......@@ -52,7 +52,7 @@ public class ServicesServiceImpl implements IServicesService {
LambdaQueryWrapper<Services> lqw = buildQueryWrapper(bo);
Page<ServicesVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
Optional.ofNullable(result.getRecords()).ifPresent(records -> {
List<Notice> notices = noticeMapper.selectList();
List<Notice> notices = noticeMapper.selectList(new LambdaQueryWrapper<Notice>().eq(Notice::getSite,2));
if(null != notices && notices.size() != 0){
records.get(0).setNotice(notices.get(0).getInfo());
}
......
......@@ -26,9 +26,12 @@ import com.pz.common.enums.ShopOrderStatus;
import com.pz.common.enums.TotalOrderStatus;
import com.pz.common.exception.ServiceException;
import com.pz.common.utils.HttpUtils;
import com.pz.merchant.domain.Company;
import com.pz.merchant.domain.Employees;
import com.pz.merchant.domain.vo.EmployeesVo;
import com.pz.common.utils.JsonUtils;
import com.pz.merchant.domain.vo.SonOrderVo;
import com.pz.merchant.mapper.CompanyMapper;
import com.pz.merchant.mapper.EmployeesMapper;
import com.pz.merchant.service.ISonOrderService;
import com.pz.merchant.service.impl.SonOrderServiceBuilder;
......@@ -123,6 +126,8 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
private final UserRefundMapper userRefundMapper;
private final CompanyMapper companyMapper;
@Override
public TotalOrderVo queryById(Long id) {
return baseMapper.selectVoById(id);
......@@ -360,6 +365,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
List<Integer> ids = JsonUtils.parseArray(storeGoods.getTags(), Integer.class);
List<StoreGoodsTag> storeGoodsTags = storeGoodsTagMapper.selectList(new LambdaQueryWrapper<StoreGoodsTag>().in(StoreGoodsTag::getId, ids).select(StoreGoodsTag::getTitle));
totalOrderVo.setTags(storeGoodsTags);
totalOrderVo.setPrice(storeGoods.getPrice());
totalOrderVo.setName(storeGoods.getTitle());
}
......@@ -495,6 +501,18 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
} else if (bo.getBusinessId() == 0) {// 商城订单
StoreOrder storeOrder = BeanUtil.toBean(bo, StoreOrder.class);
StoreGoods storeGoods1 = storeGoodsMapper.selectById(storeOrder.getGoodsId());
if(storeGoods1.getInventory() == 0){
throw new ServiceException("商品库存不足!");
}
//扣除库存
storeGoods1.setId(storeOrder.getId());
storeGoods1.setInventory(storeGoods1.getInventory() - storeOrder.getNum());
storeGoods1.setSaleNum(storeGoods1.getSaleNum() + 1);
storeGoodsMapper.updateById(storeGoods1);
storeOrderMapper.insert(storeOrder);
}
......@@ -551,10 +569,22 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
totalOrderBo.setIsRefund(0);
return this.refundOrder(totalOrderBo);
}
/*
if(){
}*/
if (sonOrderSimpleDataByTotalId.getOrderStatus() == 0 && totalOrder.getEmId() == 0 && totalOrder.getStatus() == 0) {// 预约陪诊
// yypzOrderMapper.selectOne(new LambdaQueryWrapper<YypzOrder>().eq(YypzOrder::getOrderId,totalOrder));
totalOrder.setStatus(TotalOrderStatus.CANCEL.getCode());
if(totalOrder.getBusinessId() == 0){
StoreOrder storeOrder = storeOrderMapper.selectById(sonOrderSimpleDataByTotalId.getSonOrderId());
StoreGoods storeGoods = storeGoodsMapper.selectById(storeOrder.getGoodsId());
storeGoods.setSaleNum(storeGoods.getSaleNum() - 1);
storeGoods.setInventory(storeGoods.getInventory() + 1);
storeGoodsMapper.updateById(storeGoods);
}
return baseMapper.updateById(totalOrder) > 0;
} else {
throw new ServiceException("该订单已分配给陪诊员,不允许取消订单!");
......@@ -567,6 +597,42 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
TotalOrder totalOrder = BeanUtil.toBean(bo, TotalOrder.class);
totalOrder.setStatus(TotalOrderStatus.DONE.getCode());
TotalOrder totalOrder1 = baseMapper.selectById(totalOrder.getId());
//除了商城订单和诊前挂号不需要给陪诊员和商户分成
if(totalOrder1.getBusinessId() != 0 && totalOrder1.getBusinessId() != 6){
Services services = servicesMapper.selectById(totalOrder1.getServiceId());
if(services.getFenmo() != 0){
double money = 0;
Employees employees = employeesMapper.selectById(totalOrder1.getEmId());
/**
* 1. 如果该陪诊员不属于任何商户,则陪诊员每完成一个订单,收益都会相应增加
* 2. 如果该陪诊员属于某个商户,则该陪诊员每完成一个订单,收益不会增加(因为陪诊员完成订单后,收益暂归商户所有)
*/
double fenmo = (double) services.getFenmo() / 100;
double v = totalOrder.getPayMoney() * fenmo;
money = v;
if(employees.getCompanyId() != 0){
Company company = companyMapper.selectById(employees.getCompanyId());
company.setTotalRevenue(company.getTotalRevenue() + money);
company.setBalance(company.getBalance() + money);
companyMapper.updateById(company);
}else {
employees.setTotalRevenue(employees.getTotalRevenue());
employees.setBalance(employees.getBalance());
employeesMapper.updateById(employees);
}
}
}
return baseMapper.updateById(totalOrder) > 0;
}
......@@ -637,7 +703,41 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
// 修改子订单状态
boolean sonOrderFlag = orderService.switchSonOrderStatus(totalOrder.getId(), CommonOrderStatus.REFUND.getCode());
if (sonOrderFlag) {
//除了商城订单和诊前挂号不需要给陪诊员和商户分成
if(totalOrder.getBusinessId() != 0 && totalOrder.getBusinessId() != 6){
Services services = servicesMapper.selectById(totalOrder.getServiceId());
if(services.getFenmo() != 0){
double money = 0;
Employees employees = employeesMapper.selectById(totalOrder.getEmId());
/**
* 1. 如果该陪诊员不属于任何商户,则陪诊员每完成一个订单,收益都会相应增加
* 2. 如果该陪诊员属于某个商户,则该陪诊员每完成一个订单,收益不会增加(因为陪诊员完成订单后,收益暂归商户所有)
*/
double fenmo = (double) services.getFenmo() / 100;
double v = totalOrder.getPayMoney() * fenmo;
money = v;
if(employees.getCompanyId() != 0){
Company company = companyMapper.selectById(employees.getCompanyId());
company.setTotalRevenue(company.getTotalRevenue() - money);
company.setBalance(company.getBalance() - money);
companyMapper.updateById(company);
}else {
employees.setTotalRevenue(employees.getTotalRevenue());
employees.setBalance(employees.getBalance());
employeesMapper.updateById(employees);
}
}
}
if (!sonOrderFlag) {
throw new ServiceException("子订单状态修改出错,接单失败");
}
if (baseMapper.updateById(totalOrder) > 0) {
......@@ -707,6 +807,8 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
String serveTime = orderService.getFinishTime(totalOrder.getBusinessId());
if (StringUtils.isNotEmpty(serveTime)) {
money = getMoney(serveTime, totalOrder.getPayMoney());// 计算退款金额
}else {
money = totalOrder.getPayMoney();
}
}
......@@ -724,7 +826,7 @@ public class TotalOrderServiceImpl implements ITotalOrderService {
e.printStackTrace();
}
totalOrder.setRefundAmount(totalOrder.getPayMoney());
totalOrder.setRefundAmount(money);
} else if (bo.getIsRefund() == 1) {// 陪诊员订单完成走审批流程
if (sonOrderSimpleDataByTotalId.getOrderStatus() != 2) {
throw new ServiceException("订单状态错误");
......
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