|
@@ -10,6 +10,7 @@ import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.pj.constants.UserTypeEnum;
|
|
@@ -27,6 +28,8 @@ import com.pj.project.tb_item.TbItemService;
|
|
|
import com.pj.project.tb_item_type.TbItemType;
|
|
|
import com.pj.project.tb_item_type.TbItemTypeService;
|
|
|
import com.pj.project4sp.admin.SpAdmin;
|
|
|
+import com.pj.project4sp.role.SpRoleUtil;
|
|
|
+import com.pj.project4sp.role4permission.SpRolePermissionService;
|
|
|
import com.pj.utils.so.SoMap;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -61,64 +64,65 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
private TbItemTypeService tbItemTypeService;
|
|
|
@Resource
|
|
|
private TbBusinessItemService tbBusinessItemService;
|
|
|
+ @Autowired
|
|
|
+ SpRolePermissionService spRolePermissionService;
|
|
|
|
|
|
/**
|
|
|
* 增
|
|
|
*/
|
|
|
- public void addOrUpdate(TbBusiness t) {
|
|
|
- t.setCreateBy(StpUserUtil.getAdmin().getName());
|
|
|
+ public void addOrUpdate(TbBusiness t) {
|
|
|
+ t.setCreateBy(StpUserUtil.getAdmin().getName());
|
|
|
createCar(t.getCardNo(), t.getCardSize(), t.getGoodsName());
|
|
|
- TbDriver tbDriver= createDriver(t.getDriverIdCard(),t.getDriverName(),t.getDriverPhone());
|
|
|
+ TbDriver tbDriver = createDriver(t.getDriverIdCard(), t.getDriverName(), t.getDriverPhone());
|
|
|
t.setDriverId(tbDriver.getId());
|
|
|
- String customerId=t.getCustomerId();
|
|
|
+ String customerId = t.getCustomerId();
|
|
|
if (!StrUtil.equals(customerId, UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
|
|
|
- TbCostomer tbCostomer= tbCostomerService.getById(customerId);
|
|
|
- t.setCustomerName(tbCostomer.getName());
|
|
|
- }else {
|
|
|
+ TbCostomer tbCostomer = tbCostomerService.getById(customerId);
|
|
|
+ t.setCustomerName(tbCostomer.getName());
|
|
|
+ } else {
|
|
|
t.setConfirmInputBy(StpUserUtil.getAdmin().getName()).setConfirmInput(1).setConfirmInputTime(new Date());
|
|
|
}
|
|
|
- if (StrUtil.isEmpty(t.getNo())) {
|
|
|
- t.setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm"))+RandomUtil.randomNumbers(4));
|
|
|
- }
|
|
|
- List<TbBusinessItem>items= JSONUtil.toList(t.getItemJson(), TbBusinessItem.class);
|
|
|
- if(StrUtil.isEmpty(t.getId())){
|
|
|
- t.setCreateTime(new Date());
|
|
|
- }
|
|
|
- saveOrUpdate(t);
|
|
|
- tbBusinessItemService.removeByBusinessId(t.getId());
|
|
|
- BigDecimal price=new BigDecimal(0);
|
|
|
- for (TbBusinessItem item : items) {
|
|
|
- Integer num = item.getNum();
|
|
|
- TbItem tbItem = tbItemService.getById(item.getItemId());
|
|
|
- price = price.add(NumberUtil.mul(num, tbItem.getPrice()));
|
|
|
- TbItemType tbItemType = tbItemTypeService.getById(tbItem.getTypeId());
|
|
|
- item.setBusinessId(t.getId()).setItemCode(tbItem.getItemCode())
|
|
|
- .setItemName(tbItem.getItemName()).setItemPrice(tbItem.getPrice())
|
|
|
- .setItemTypeId(tbItem.getTypeId()).setItemTypeName(tbItemType.getName())
|
|
|
- .setUnit(tbItem.getUnit()).setTotal(NumberUtil.mul(num,tbItem.getPrice()));
|
|
|
- }
|
|
|
- t.setItemPrice(price);
|
|
|
- this.saveOrUpdate(t);
|
|
|
- tbBusinessItemService.saveBatch(items);
|
|
|
+ if (StrUtil.isEmpty(t.getNo())) {
|
|
|
+ t.setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
|
|
|
+ }
|
|
|
+ List<TbBusinessItem> items = JSONUtil.toList(t.getItemJson(), TbBusinessItem.class);
|
|
|
+ if (StrUtil.isEmpty(t.getId())) {
|
|
|
+ t.setCreateTime(new Date());
|
|
|
+ }
|
|
|
+ saveOrUpdate(t);
|
|
|
+ tbBusinessItemService.removeByBusinessId(t.getId());
|
|
|
+ BigDecimal price = new BigDecimal(0);
|
|
|
+ for (TbBusinessItem item : items) {
|
|
|
+ Integer num = item.getNum();
|
|
|
+ TbItem tbItem = tbItemService.getById(item.getItemId());
|
|
|
+ price = price.add(NumberUtil.mul(num, tbItem.getPrice()));
|
|
|
+ TbItemType tbItemType = tbItemTypeService.getById(tbItem.getTypeId());
|
|
|
+ item.setBusinessId(t.getId()).setItemCode(tbItem.getItemCode())
|
|
|
+ .setItemName(tbItem.getItemName()).setItemPrice(tbItem.getPrice())
|
|
|
+ .setItemTypeId(tbItem.getTypeId()).setItemTypeName(tbItemType.getName())
|
|
|
+ .setUnit(tbItem.getUnit()).setTotal(NumberUtil.mul(num, tbItem.getPrice()));
|
|
|
+ }
|
|
|
+ t.setItemPrice(price);
|
|
|
+ this.saveOrUpdate(t);
|
|
|
+ tbBusinessItemService.saveBatch(items);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- private TbDriver createDriver(String idCardNo,String name,String phone) {
|
|
|
- TbDriver tbDriver=tbDriverService.findByIdCardNo(idCardNo);
|
|
|
- if (tbDriver==null){
|
|
|
- tbDriver=new TbDriver();
|
|
|
+ private TbDriver createDriver(String idCardNo, String name, String phone) {
|
|
|
+ TbDriver tbDriver = tbDriverService.findByIdCardNo(idCardNo);
|
|
|
+ if (tbDriver == null) {
|
|
|
+ tbDriver = new TbDriver();
|
|
|
tbDriver.setCreateTime(new Date()).setIdCard(idCardNo).setName(name).setPhone(phone);
|
|
|
tbDriverService.save(tbDriver);
|
|
|
}
|
|
|
- return tbDriver;
|
|
|
+ return tbDriver;
|
|
|
|
|
|
}
|
|
|
|
|
|
private TbCar createCar(String cardNo, String carSize, String goodsName) {
|
|
|
TbCar tbCar = tbCarService.findByCardNo(cardNo);
|
|
|
if (tbCar == null) {
|
|
|
- tbCar = new TbCar();
|
|
|
+ tbCar = new TbCar();
|
|
|
}
|
|
|
tbCar.setCardNo(cardNo).setCardSize(carSize).setLastGoodsName(goodsName);
|
|
|
tbCarService.saveOrUpdate(tbCar);
|
|
@@ -135,8 +139,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
|
|
|
|
|
|
public void pay(String id, String payTicket) {
|
|
|
- TbBusiness tbBusiness= this.getById(id);
|
|
|
- SpAdmin admin=StpUserUtil.getAdmin();
|
|
|
+ TbBusiness tbBusiness = this.getById(id);
|
|
|
+ SpAdmin admin = StpUserUtil.getAdmin();
|
|
|
tbBusiness.setPayStatus(2).setPayBy(admin.getName())
|
|
|
.setPayBy(StpUserUtil.getAdmin().getName())
|
|
|
.setPayTicket(payTicket)
|
|
@@ -149,19 +153,27 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}
|
|
|
|
|
|
public void confirm(List<String> ids) {
|
|
|
- ids.forEach(id->{
|
|
|
- TbBusiness business=this.getById(id);
|
|
|
+ ids.forEach(id -> {
|
|
|
+ TbBusiness business = this.getById(id);
|
|
|
business.setConfirmInput(1).setConfirmInputTime(new Date()).setConfirmInputBy(StpUserUtil.getAdmin().getName());
|
|
|
this.updateById(business);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
public void adminConfirmPay(List<String> ids) {
|
|
|
- ids.forEach(id->{
|
|
|
- TbBusiness business=this.getById(id);
|
|
|
- business.setAdminConfirmPayTime(new Date()).setAdminConfirmPay(1).setAdminConfirmPayBy(StpUserUtil.getAdmin().getName())
|
|
|
- .setPayStatus(3);
|
|
|
+ ids.forEach(id -> {
|
|
|
+ TbBusiness business = this.getById(id);
|
|
|
+ business.setAdminConfirmPayTime(new Date()).setAdminConfirmPay(1).setAdminConfirmPayBy(StpUserUtil.getAdmin().getName())
|
|
|
+ .setPayStatus(3);
|
|
|
this.updateById(business);
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ public TbBusiness findCarTheNewRecord(String carNo) {
|
|
|
+ QueryWrapper<TbBusiness> ew = new QueryWrapper<>();
|
|
|
+ ew.eq("card_no", carNo);
|
|
|
+ ew.orderByDesc("id");
|
|
|
+ List<TbBusiness> list = this.list(ew);
|
|
|
+ return list.isEmpty() ? null : list.get(0);
|
|
|
+ }
|
|
|
}
|