This commit is contained in:
cun-nan 2024-01-17 18:17:57 +08:00
parent 0111c8055c
commit 4df95eff14
5 changed files with 73 additions and 32 deletions

View File

@ -9,6 +9,7 @@ import com.fuint.api.fuyou.entity.*;
import com.fuint.api.fuyou.service.FyPayService;
import com.fuint.api.fuyou.service.MerchantConfigService;
import com.fuint.api.fuyou.util.Utils;
import com.fuint.business.commission.service.StaffCommissionService;
import com.fuint.business.integral.entity.IntegralOrders;
import com.fuint.business.integral.service.IntegralOrdersService;
import com.fuint.business.marketingActivity.cardFavorable.entity.CardFavorableRecord;
@ -45,6 +46,9 @@ public class FyPayServiceImpl implements FyPayService {
private CardFuelRecordService cardFuelRecordService;
@Resource
private IntegralOrdersService integralOrdersService;
@Autowired
private StaffCommissionService staffCommissionService;
/**
* 条码支付
* @param map1
@ -171,7 +175,7 @@ public class FyPayServiceImpl implements FyPayService {
// 油品订单
oilOrder.setOrderStatus("paid");
oilOrder.setPayTime(date);
staffCommissionService.countStaffCommission(oilOrder.getStaffId(),oilOrder.getStoreId(),oilOrder.getOrderAmount(),oilOrder.getPayAmount(),oilOrder.getOilNum(),"油品",orderNo);
// 修改油罐容量
List<JSONObject> jsonObjects = JSONArray.parseArray(map1.get("oilOrder"), JSONObject.class);
if (jsonObjects.size()<=1) {
@ -193,7 +197,7 @@ public class FyPayServiceImpl implements FyPayService {
// 商品订单
goodsOrder.setStatus("paid");
goodsOrder.setPayTime(date);
staffCommissionService.countStaffCommission(goodsOrder.getStaffId(),goodsOrder.getStoreId(),goodsOrder.getAmount(),goodsOrder.getPayAmount(),0.0,"商品",orderNo);
if (!map1.get("goodsOrder").equals("[]")){
List<JSONObject> goods = JSONArray.parseArray(map1.get("goodsOrder"), JSONObject.class);
OrderGoods orderGoods = new OrderGoods();
@ -225,6 +229,9 @@ public class FyPayServiceImpl implements FyPayService {
if (!ArrayUtil.isEmpty(list)){
if (list.size()>1){
for (OilOrder order : list) {
if (order.getOrderType().equals("主订单")){
staffCommissionService.countStaffCommission(order.getStaffId(),order.getStoreId(),order.getOrderAmount(),order.getPayAmount(),order.getOilNum(),"油品",orderNo);
}
// 添加多个油品订单
order.setOrderStatus("paid");
order.setPayTime(date);

View File

@ -11,6 +11,8 @@ import com.fuint.business.commission.mapper.StaffCommissionMapper;
import com.fuint.business.commission.service.CommissionRecordService;
import com.fuint.business.commission.service.StaffCommissionService;
import com.fuint.business.commission.vo.StaffCommissionVo;
import com.fuint.business.member.entity.LJStaff;
import com.fuint.business.member.service.ILJStaffService;
import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.TokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -94,18 +96,21 @@ public class StaffCommissionServiceImpl extends ServiceImpl<StaffCommissionMappe
@Autowired
private CommissionRecordService commissionRecordService;
@Autowired
private ILJStaffService staffService;
@Override
public void countStaffCommission(Integer staffId,Integer storeId,Double amount,Double payAmount,Double oilLiters,String type,String orderNo) {
LJStaff staff = staffService.selectStaffById(staffId);
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id",storeId);
queryWrapper.eq("status","qy");
// 查询当前店铺启用的提成方案信息
List<StaffCommission> list = baseMapper.selectList(queryWrapper);
if (list.size()>0){
if (list.size()>0 && ObjectUtil.isNotEmpty(staff)){
for (StaffCommission staffCommission : list) {
CommissionRecord commissionRecord = new CommissionRecord();
if (type.equals(staffCommission.getCommissionSource())){
if (type.equals(staffCommission.getCommissionSource()) && staff.getRoleId().equals(staffCommission.getStaffRoleGroup())){
commissionRecord.setStaffId(staffId);
commissionRecord.setStoreId(storeId);
commissionRecord.setType(type+"订单出售");

View File

@ -79,7 +79,13 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper,AllO
@Override
public int insertAllOrderInfo(AllOrderInfo allOrderInfo) {
return baseMapper.insert(allOrderInfo);
int row = 0;
AllOrderInfo allOrderInfo1 = this.selectAllOrderInfoByOrderNo(allOrderInfo.getOrderNo());
if (ObjectUtil.isNotEmpty(allOrderInfo1)){
return row;
}
row = baseMapper.insert(allOrderInfo);
return row;
}

View File

@ -1,5 +1,6 @@
package com.fuint.business.order.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -73,7 +74,13 @@ public class CashierOrderServiceImpl extends ServiceImpl<CashierOrderMapper, Cas
@Override
public int insertCashierOrder(CashierOrder order) {
int row = baseMapper.insert(order);
CashierOrder cashierOrder = this.selectCashierOrder(order.getOrderNo());
int row = 0;
if (ObjectUtil.isNotEmpty(cashierOrder)){
row = 0;
return row;
}
row = baseMapper.insert(order);
return row;
}

View File

@ -13,6 +13,7 @@ import com.fuint.api.fuyou.entity.ReceiveParameter;
import com.fuint.api.fuyou.service.FyPayService;
import com.fuint.api.fuyou.service.MerchantConfigService;
import com.fuint.api.fuyou.service.OilConfigService;
import com.fuint.business.commission.service.StaffCommissionService;
import com.fuint.business.convenienceSore.entity.LJGoods;
import com.fuint.business.convenienceSore.service.LJGoodsService;
import com.fuint.business.marketingActivity.cardFule.entity.CardFuelRecord;
@ -89,6 +90,8 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
private OilConfigService oilConfigService;
@Autowired
private LJGoodsService goodsService;
@Autowired
private StaffCommissionService staffCommissionService;
@Override
public IPage<OilOrder> selectOilOrderList(Page page, OilOrder order) {
@ -245,8 +248,6 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
payStatus = "unpaid";
}
Map<String,Object> orders = new HashMap<>();
OilOrder oilOrder1 = null;
@ -278,6 +279,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
ljOrder.setStaffId(staffId);
ljOrder.setStatus(payStatus);
if (payType.equals("CASH")){
staffCommissionService.countStaffCommission(staffId,storeId,goodsAmount,goodsActualPay,0.0,"商品",orderNo);
ljOrder.setPayTime(new Date());
}
// 将商品订单的json数据转换为数组
@ -309,28 +311,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
ljOrder1 = orderService.selectGoodsOrder(orderNo);
}
// 添加收银台订单信息
CashierOrder cashierOrder = new CashierOrder();
cashierOrder.setStaffId(staffId);
cashierOrder.setStoreId(storeId);
cashierOrder.setPayUser(payUser);
cashierOrder.setAmount(oilAmount+goodsAmount);
cashierOrder.setStatus(payStatus);
if (payType.equals("CASH")){
cashierOrder.setPayAmount(Double.valueOf(map.get("authCode")));
cashierOrder.setPayTime(new Date());
this.insertAllOrderInfo(orderNo,storeId,Double.valueOf(map.get("allAmount")),payType,userId,"PC","6","paid");
}else {
cashierOrder.setPayAmount(oilActualPay+goodsActualPay);
}
cashierOrder.setSeekZero(seekZero);
cashierOrder.setOrderNo(orderNo);
cashierOrder.setGoodsOrderAmount(goodsAmount);
cashierOrder.setGoodsDiscountAmount(goodsDiscount);
cashierOrder.setOilOrderAmount(oilAmount);
cashierOrder.setOilDiscountAmount(oilDiscount);
cashierOrder.setTerminal(terminal);
cashierOrder.setPayType(payType);
Double oilLiters = 0.0;
// 添加油品订单信息
if (!oilOrder.equals("[]")){
@ -341,11 +322,15 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
Double amount = Double.valueOf(jsonObjects.get(i).get("amount").toString());
Double oilPrice = Double.valueOf(jsonObjects.get(i).get("oilPrice").toString());
Double oilNum = amount/oilPrice;
oilLiters += oilNum;
if (i==0){
order.setOrderType("主订单");
order.setOrderAmount(amount);
order.setPayAmount(oilActualPay);
order.setOrderNo(orderNo);
if (payType.equals("CASH")){
staffCommissionService.countStaffCommission(staffId,storeId,oilAmount,oilActualPay,oilLiters,"油品",orderNo);
}
}else {
order.setOrderType("子订单");
order.setOrderAmount(amount);
@ -384,6 +369,29 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
}
}
// 添加收银台订单信息
CashierOrder cashierOrder = new CashierOrder();
cashierOrder.setStaffId(staffId);
cashierOrder.setStoreId(storeId);
cashierOrder.setPayUser(payUser);
cashierOrder.setAmount(oilAmount+goodsAmount);
cashierOrder.setStatus(payStatus);
if (payType.equals("CASH")){
cashierOrder.setPayAmount(Double.valueOf(map.get("authCode")));
cashierOrder.setPayTime(new Date());
this.insertAllOrderInfo(orderNo,storeId,Double.valueOf(map.get("allAmount")),payType,userId,"PC","6","paid");
}else {
cashierOrder.setPayAmount(oilActualPay+goodsActualPay);
}
cashierOrder.setSeekZero(seekZero);
cashierOrder.setOrderNo(orderNo);
cashierOrder.setGoodsOrderAmount(goodsAmount);
cashierOrder.setGoodsDiscountAmount(goodsDiscount);
cashierOrder.setOilOrderAmount(oilAmount);
cashierOrder.setOilDiscountAmount(oilDiscount);
cashierOrder.setTerminal(terminal);
cashierOrder.setPayType(payType);
// 如果金额不等于0调用第三方支付接口
if (!map.get("allAmount").equals("0") && !map.get("payType").equals("CASH")){
Integer allAmount = (int) (Double.valueOf(map.get("allAmount"))*100);
@ -505,6 +513,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
// 添加收银台订单信息
CashierOrder cashierOrder = new CashierOrder();
boolean flag = false;
Double oilLiters = 0.0;
for (int i = 0;i < oilOrders.size();i++) {
if (oilOrders.get(i).get("oilName").equals(oilName.getId().toString())){
Double amount = Double.valueOf(oilOrders.get(i).get("amount").toString());
@ -513,6 +522,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
flag = true;
status = "paid";
Double oilNum = amount / oilPrice;
oilLiters += oilNum;
if (i == 0) {
order.setOrderType("主订单");
order.setOrderAmount(amount);
@ -549,6 +559,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
flag = true;
status = "paid";
Double oilNum = amount / oilPrice;
oilLiters += oilNum;
if (i == 0) {
order.setOrderType("主订单");
order.setOrderAmount(amount);
@ -585,6 +596,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
flag = true;
status = "paid";
Double oilNum = amount / oilPrice;
oilLiters += oilNum;
if (i == 0) {
order.setOrderType("主订单");
order.setOrderAmount(amount);
@ -617,7 +629,6 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
oilOrder = this.selectOilOrderByOrderNo(orderNo);
this.updateGrowthValue1(oilAmount,userId, Integer.valueOf(oilOrder.getOils()),0.0,storeId,orderNo);
// this.insertCardBalance((Double.valueOf(oilOrders.get(i).get("liters").toString())-refuelMoneyLiters)*oilPrice,userId,storeId);
}else {
res.put("error","囤油卡或储值卡余额不足!");
}
@ -642,6 +653,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
cashierOrder.setPayType(map.get("payType"));
cashierOrderService.insertCashierOrder(cashierOrder);
this.insertAllOrderInfo(orderNo, storeId, oilAmount, map.get("payType"), userId, "PC", "1", status);
staffCommissionService.countStaffCommission(Integer.valueOf(map.get("staffId")),storeId,oilAmount,oilAmount,oilLiters,"油品",orderNo);
res.put("success","success");
}
}
@ -650,10 +662,12 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
if (cardBalance>=oilAmount){
// 添加油品订单信息
OilOrder order = new OilOrder();
Double oilLiters = 0.0;
for (int i = 0;i < oilOrders.size();i++) {
Double amount = Double.valueOf(oilOrders.get(i).get("amount").toString());
Double oilPrice = Double.valueOf(oilOrders.get(i).get("oilPrice").toString());
Double oilNum = amount / oilPrice;
oilLiters += oilNum;
if (i == 0) {
order.setOrderType("主订单");
order.setOrderAmount(amount);
@ -704,7 +718,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
cashierOrderService.insertCashierOrder(cashierOrder);
this.updateGrowthValue1(oilAmount,userId, Integer.valueOf(oilOrder.getOils()),0.0,storeId,orderNo);
this.insertAllOrderInfo(orderNo,accountInfo.getStoreId(),oilAmount,map.get("payType"),userId,"PC","1","paid");
staffCommissionService.countStaffCommission(Integer.valueOf(map.get("staffId")),storeId,oilAmount,oilAmount,oilLiters,"油品",orderNo);
// this.insertCardBalance(oilAmount,userId,storeId);
res.put("success","success");
}else {
@ -997,6 +1011,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
this.updateGrowthValue(payAmount,userId, Integer.valueOf(oilOrder.getOils()),oilCardAmount,oilOrder.getStoreId(),orderNo);
this.addOilTracks(oilOrder,oilOrder.getStoreId());
this.insertCardOrder(oilOrder.getUserId(),oilOrder.getStoreId(),orderNo,oilOrder.getOrderAmount(),"paid", Double.valueOf(balanceAmount),payAmount);
staffCommissionService.countStaffCommission(oilOrder.getStaffId(),oilOrder.getStoreId(),oilOrder.getOrderAmount(),oilOrder.getOrderAmount(),oilOrder.getOilNum(),"油品",orderNo);
oilOrder.setPayAmount(payAmount);
oilOrder.setDiscountAmount(Double.valueOf(discountAmount));
oilOrder.setPayTime(new Date());
@ -1067,6 +1082,7 @@ public class OilOrderServiceImpl extends ServiceImpl<OilOrderMapper, OilOrder> i
}
this.updateGrowthValue(oilOrder.getPayAmount(),userId, Integer.valueOf(oilOrder.getOils()),null,oilOrder.getStoreId(),orderNo);
this.addOilTracks(oilOrder,oilOrder.getStoreId());
staffCommissionService.countStaffCommission(oilOrder.getStaffId(),oilOrder.getStoreId(),oilOrder.getOrderAmount(),oilOrder.getPayAmount(),oilOrder.getOilNum(),"油品",orderNo);
CashierOrder cashierOrder = cashierOrderService.selectCashierOrder(orderNo);
if (ObjectUtil.isNotEmpty(cashierOrder)){
cashierOrder.setOilOrderId(oilOrder.getId());