添加交班时间

This commit is contained in:
牛叉闪闪
2024-07-22 14:11:48 +08:00
parent cda3245f7b
commit 60267f5576
13 changed files with 284 additions and 21 deletions

View File

@@ -5,6 +5,8 @@ import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.po.ProductInfo;
import com.chaozhanggui.system.cashierservice.entity.po.ProductInfoPO;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.model.CategoryInfo;
import com.chaozhanggui.system.cashierservice.model.HandoverInfo;
@@ -562,7 +564,7 @@ public class CloudPrinterService {
}
public Result handoverprintData(String token,Integer id,String loginName){
public Result handoverprintData(String token,Integer id,String loginName,boolean isprintProduct){
JSONObject info= TokenUtil.parseParamFromToken(token);
@@ -642,6 +644,13 @@ public class CloudPrinterService {
productCategories=JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(categries),HandoverInfo.ProductCategory.class);
}
List<ProductInfoPO> productInfoPOS=null;
List<ProductInfo> productInfos=null;
if(isprintProduct){
// productInfoPOS=shopUserDutyPayMapper.selectProductByDutyId(shopUserDuty.getId());
productInfos=shopUserDutyMapper.selectByDutyId(shopUserDuty.getId());
}
HandoverInfo handoverInfo=new HandoverInfo(tbShopInfo.getShopName(),
ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime())?DateUtils.getTime(shopUserDuty.getLoginTime()):null,
@@ -653,7 +662,9 @@ public class CloudPrinterService {
shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).toPlainString(),
shopUserDuty.getReturnAmount().toPlainString(),
shopUserDuty.getOrderNum().toString(),
productCategories,ObjectUtil.isNull(shopUserDuty.getQuickAmount())?"0":shopUserDuty.getQuickAmount().toPlainString()
productCategories,ObjectUtil.isNull(shopUserDuty.getQuickAmount())?"0":shopUserDuty.getQuickAmount().toPlainString(),
productInfoPOS,
productInfos
);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";

View File

@@ -4,6 +4,8 @@ import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.entity.po.ProductInfo;
import com.chaozhanggui.system.cashierservice.entity.po.ProductInfoPO;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.model.HandoverInfo;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
@@ -111,11 +113,108 @@ public class DataService {
shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).toPlainString(),
shopUserDuty.getReturnAmount().toPlainString(),
shopUserDuty.getOrderNum().toString(),
productCategories,ObjectUtil.isNull(shopUserDuty.getQuickAmount())?"0":shopUserDuty.getQuickAmount().toPlainString()
productCategories,ObjectUtil.isNull(shopUserDuty.getQuickAmount())?"0":shopUserDuty.getQuickAmount().toPlainString(),
null,null
);
return Result.success(CodeEnum.SUCCESS,handoverInfo);
}
public Result handoverprint(Integer id,boolean isprintProduct){
ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByPrimaryKey(id);
// ShopUserDuty shopUserDuty=shopUserDutyMapper.selectByShopIdAndDay(tbShopInfo.getId(),tradeDay);
MsgException.checkNull(shopUserDuty, "交班信息不存在");
TbShopInfo tbShopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopUserDuty.getShopId()));
MsgException.checkNull(tbShopInfo,"店铺信息不存在");
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(tbShopInfo.getId());
if (ObjectUtil.isEmpty(shopInfo)) {
log.error("店铺信息不存在");
return Result.fail(CodeEnum.SHOPINFONOEXIST);
}
List<TbPrintMachineWithBLOBs> bloBsList = tbPrintMachineMapper.selectByShopId(tbShopInfo.getId().toString());
if (ObjectUtil.isEmpty(bloBsList) || bloBsList.size() <= 0) {
log.error("此店铺没有对应的打印机设备");
return Result.fail(CodeEnum.printmachinenoexsit);
}
bloBsList.parallelStream().forEach(it-> {
if (!"network".equals(it.getConnectionType())) {
log.error("非网络打印机");
return;
}
if (!"1".equals(it.getStatus().toString())) {
log.error("打印机状态异常");
return;
}
if (!it.getSubType().equals("cash")) {
log.error("非小票打印机");
return;
}
List<HandoverInfo.PayInfo> list = null;
List<HandoverInfo.MemberData> memberData = null;
List<HandoverInfo.ProductCategory> productCategories = null;
List<Map<String, Object>> mapList = shopUserDutyPayMapper.selectByDutyId(shopUserDuty.getId());
if (ObjectUtil.isNotEmpty(mapList) && mapList.size() > 0) {
list = JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(mapList), HandoverInfo.PayInfo.class);
}
memberData = new ArrayList<>();
ShopUserDutyPay shopUserDutyPay = shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(), "deposit");
if (ObjectUtil.isNotEmpty(shopUserDutyPay)) {
memberData.add(new HandoverInfo.MemberData(shopUserDutyPay.getAmount().toPlainString(), "会员卡消费"));
}
memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberInAmount()) ? BigDecimal.ZERO.toPlainString() : shopUserDuty.getMemberInAmount().toPlainString(), "会员卡充值"));
List<Map<String, Object>> categries = shopUserDutyPayMapper.selectCetoryBydutyId(shopUserDuty.getId());
if (ObjectUtil.isNotEmpty(categries) && categries.size() > 0) {
productCategories = JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(categries), HandoverInfo.ProductCategory.class);
}
List<ProductInfoPO> productInfoPOS = null;
List<ProductInfo> productInfos = null;
if (isprintProduct) {
// productInfoPOS=shopUserDutyPayMapper.selectProductByDutyId(shopUserDuty.getId());
productInfos = shopUserDutyMapper.selectByDutyId(shopUserDuty.getId());
}
HandoverInfo handoverInfo = new HandoverInfo(tbShopInfo.getShopName(),
ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime()) ? DateUtils.getTime(shopUserDuty.getLoginTime()) : null,
ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime()) ? DateUtils.getTime(shopUserDuty.getLoginOutTime()) : "",
"",
list, memberData, shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? BigDecimal.ZERO : shopUserDuty.getQuickAmount()).toPlainString(),
"0",
shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(),
shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? BigDecimal.ZERO : shopUserDuty.getQuickAmount()).toPlainString(),
shopUserDuty.getReturnAmount().toPlainString(),
shopUserDuty.getOrderNum().toString(),
productCategories, ObjectUtil.isNull(shopUserDuty.getQuickAmount()) ? "0" : shopUserDuty.getQuickAmount().toPlainString(),
null, productInfos
);
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
PrinterUtils.printTickets(voiceJson, 1, 1, it.getAddress(), PrinterUtils.handoverprintData(handoverInfo));
});
return Result.success(CodeEnum.SUCCESS);
}
}

View File

@@ -156,11 +156,11 @@ public class DutyService {
// ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByTokenId(tokenId);
ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndStatus(shopId, "0");
// ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndTrade(shopId, day);
// ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByTokenIdAndTradeDay(tokenId, day, orderInfo.getShopId());
// ShopUserDuty shopU serDuty = shopUserDutyMapper.selectByTokenIdAndTradeDay(tokenId, day, orderInfo.getShopId());
BigDecimal cashAmount = BigDecimal.ZERO;
if (type.equals("create")) {
if (orderInfo.getPayType().equals("cash")) {
if ("cash".equals(orderInfo.getPayType())) {
cashAmount = orderInfo.getPayAmount();
}
if (Objects.isNull(shopUserDuty)) {
@@ -362,7 +362,7 @@ public class DutyService {
Integer shopId = tokenJson.getInteger("shopId");
Integer staffId = tokenJson.getInteger("staffId");
ShopUserDuty shopUserDuty = shopUserDutyMapper.selectByShopIdAndStatus(shopId, "0");
cloudPrinterService.handoverprintData(token, shopUserDuty.getId(), "");
cloudPrinterService.handoverprintData(token, shopUserDuty.getId(), "",true);
// shopUserDutyMapper.updateStatusByTokenId(day, shopId, staffId);
shopUserDutyMapper.updateStatusById(shopUserDuty.getId(), staffId);
}

View File

@@ -173,6 +173,8 @@ public class LoginService {
jsonObject.put("type", "close");
jsonObject.put("token", token);
rabbitProducer.putOrderCollect(jsonObject.toJSONString());
return Result.success(SUCCESS);
}