|
@@ -19,6 +19,7 @@ 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;
|
|
|
+import com.pj.current.config.CarConfig;
|
|
|
import com.pj.current.config.PartConfig;
|
|
|
import com.pj.current.satoken.StpUserUtil;
|
|
|
import com.pj.project.tb_business_item.TbBusinessItem;
|
|
@@ -45,6 +46,7 @@ import com.pj.project4sp.role4permission.SpRolePermissionService;
|
|
|
import com.pj.utils.so.SoMap;
|
|
|
import org.aspectj.weaver.loadtime.Aj;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -85,6 +87,8 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
TbBusinessPeopleService tbBusinessPeopleService;
|
|
|
@Resource
|
|
|
private PartConfig partConfig;
|
|
|
+ @Resource
|
|
|
+ private CarConfig carConfig;
|
|
|
|
|
|
@Resource
|
|
|
private TbPassRecordService tbPassRecordService;
|
|
@@ -93,7 +97,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
public TbBusiness checkCarNo(String carNo) {
|
|
|
QueryWrapper<TbBusiness> ew = new QueryWrapper<>();
|
|
|
ew.eq("card_no", carNo)
|
|
|
- .eq("admin_confirm_out",0);
|
|
|
+ .eq("admin_confirm_out", 0);
|
|
|
return this.getOne(ew);
|
|
|
}
|
|
|
|
|
@@ -101,12 +105,20 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
* 增
|
|
|
*/
|
|
|
public AjaxJson addOrUpdate(TbBusiness t) {
|
|
|
- if (checkCarNo(t.getCardNo()) != null&&StrUtil.isEmpty(t.getId())) {
|
|
|
+ if (checkCarNo(t.getCardNo()) != null && StrUtil.isEmpty(t.getId())) {
|
|
|
return AjaxJson.getError("该车辆【" + t.getCardNo() + "】有未完成业务");
|
|
|
}
|
|
|
- if (checkCarNo(t.getChinaCarNo()) != null&&StrUtil.isEmpty(t.getId())) {
|
|
|
+ if (checkCarNo(t.getChinaCarNo()) != null && StrUtil.isEmpty(t.getId())) {
|
|
|
return AjaxJson.getError("该车辆【" + t.getChinaCarNo() + "】有未完成业务");
|
|
|
}
|
|
|
+ double carSize = t.getCardSize();
|
|
|
+ if (carSize > carConfig.getMaxLength()) {
|
|
|
+ return AjaxJson.getError("车辆规格不能大于" + carConfig.getMaxLength());
|
|
|
+ }
|
|
|
+ double netWeight = t.getNetWeight();
|
|
|
+ if (netWeight > carConfig.getMaxWeight()) {
|
|
|
+ return AjaxJson.getError("车辆载重不能大于" + carConfig.getMaxWeight());
|
|
|
+ }
|
|
|
t.setCreateBy(StpUserUtil.getAdmin().getName());
|
|
|
createCarUnit(t);
|
|
|
String customerId = t.getCustomerId();
|
|
@@ -120,9 +132,9 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
if (StrUtil.isEmpty(t.getId())) {
|
|
|
t.setCreateTime(new Date());
|
|
|
t.setNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm")) + RandomUtil.randomNumbers(4));
|
|
|
- BusinessMessageManager.set(t.getCustomerId(),"您有一条新的业务数据:【"+t.getNo()+"】");
|
|
|
- }else {
|
|
|
- BusinessMessageManager.set(t.getCustomerId(),"您的业务数据:【"+t.getNo()+"】发生更改");
|
|
|
+ storeMsg(t.getCustomerId(), "新增一条业务数据:【" + t.getNo() + "】" + DateUtil.now() + "。");
|
|
|
+ } else {
|
|
|
+ storeMsg(t.getCustomerId(), "业务订单:【" + t.getNo() + "】数据发生更改," + DateUtil.now() + "。");
|
|
|
}
|
|
|
List<TbBusinessItem> items = JSONUtil.toList(t.getItemJson(), TbBusinessItem.class);
|
|
|
saveOrUpdate(t);
|
|
@@ -153,6 +165,15 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
return AjaxJson.getSuccess();
|
|
|
}
|
|
|
|
|
|
+ public void storeMsg(String businessCustomerId, String content) {
|
|
|
+ String currentCustomerId = StpUserUtil.getCustomerId();
|
|
|
+ if (StrUtil.equals(currentCustomerId, UserTypeEnum.PLATFORM_ADMIN.getCustomerId())) {
|
|
|
+ BusinessMessageManager.set(businessCustomerId, content);
|
|
|
+ } else {
|
|
|
+ BusinessMessageManager.set(UserTypeEnum.PLATFORM_ADMIN.getCustomerId(), content);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void createBusinessPeople(TbBusiness t) {
|
|
|
tbBusinessPeopleService.removeByBusinessId(t.getId());
|
|
|
List<TbBusinessPeople> peopleList = JSONUtil.toList(t.getPeopleJson(), TbBusinessPeople.class);
|
|
@@ -219,7 +240,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
.setAdminConfirmPayBy(admin.getName()).setAdminConfirmPayTime(new Date());
|
|
|
}
|
|
|
this.updateById(tbBusiness);
|
|
|
- BusinessMessageManager.set(tbBusiness.getCustomerId(),"您的业务订单【"+tbBusiness.getNo()+"】已支付");
|
|
|
+ storeMsg(tbBusiness.getCustomerId(), "业务订单【" + tbBusiness.getNo() + "】已支付" + DateUtil.now() + "。");
|
|
|
}
|
|
|
|
|
|
public void confirm(List<String> ids) {
|
|
@@ -227,7 +248,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
TbBusiness business = this.getById(id);
|
|
|
business.setConfirmInput(1).setConfirmInputTime(new Date()).setConfirmInputBy(StpUserUtil.getAdmin().getName());
|
|
|
this.updateById(business);
|
|
|
- BusinessMessageManager.set(business.getCustomerId(),"您的业务订单【"+business.getNo()+"】已确认");
|
|
|
+ storeMsg(business.getCustomerId(), "业务订单【" + business.getNo() + "】已确认" + DateUtil.now() + "。");
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -237,20 +258,21 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
business.setAdminConfirmPayTime(new Date()).setAdminConfirmPay(1).setAdminConfirmPayBy(StpUserUtil.getAdmin().getName())
|
|
|
.setPayStatus(3).setPayTicket(ticket);
|
|
|
this.updateById(business);
|
|
|
- BusinessMessageManager.set(business.getCustomerId(),"您的业务订单【"+business.getNo()+"】已确认支付");
|
|
|
+ storeMsg(business.getCustomerId(), "业务订单【" + business.getNo() + "】已确认支付" + DateUtil.now() + "。");
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- public TbBusiness findCarTheNewRecord(String carNo,int inOrOut) {
|
|
|
+ public TbBusiness findCarTheNewRecord(String carNo, int inOrOut) {
|
|
|
QueryWrapper<TbBusiness> ew = new QueryWrapper<>();
|
|
|
ew.eq("card_no", carNo);
|
|
|
- if (inOrOut==1){
|
|
|
- ew.eq("admin_confirm_in",0).isNull("in_channel");
|
|
|
- }else {
|
|
|
- ew.eq("admin_confirm_out",0).isNull("out_channel").isNotNull("real_in_time");
|
|
|
+ if (inOrOut == 1) {
|
|
|
+ ew.eq("admin_confirm_in", 0).isNull("in_channel");
|
|
|
+ } else {
|
|
|
+ ew.eq("admin_confirm_out", 0).isNull("out_channel").isNotNull("real_in_time");
|
|
|
}
|
|
|
return getOne(ew);
|
|
|
}
|
|
|
+
|
|
|
@Deprecated
|
|
|
public void adminConfirmIn(String id, String inChannel) {
|
|
|
TbBusiness tbBusiness = this.getById(id);
|
|
@@ -281,6 +303,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
tbBusiness.getChinaCarInTime(), tbBusiness.getChinaCarOutTime(), "中国车");
|
|
|
|
|
|
}
|
|
|
+
|
|
|
@Async
|
|
|
public void calculationPartMoney(String itemType, TbBusiness tbBusiness) {
|
|
|
Date iTime = tbBusiness.getRealInTime();
|
|
@@ -303,7 +326,7 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
long hour = ChronoUnit.HOURS.between(inDayTime, outDayTime);
|
|
|
BigDecimal basePrice = partConfig.getBasePrice();
|
|
|
BigDecimal extraPrice = partConfig.getExtraPrice();
|
|
|
- BigDecimal price = basePrice.add(basePrice.multiply(new BigDecimal(hour/24))).add(new BigDecimal(days).multiply(extraPrice));
|
|
|
+ BigDecimal price = basePrice.add(basePrice.multiply(new BigDecimal(hour / 24))).add(new BigDecimal(days).multiply(extraPrice));
|
|
|
if (itemType.contains("中国")) {
|
|
|
tbBusiness.setChinaPartMoney(price).setChinaCarPartTime(minutes);
|
|
|
} else {
|
|
@@ -313,22 +336,21 @@ public class TbBusinessService extends ServiceImpl<TbBusinessMapper, TbBusiness>
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* @param carNo
|
|
|
* @param inOrOut 1入 2出
|
|
|
* @return
|
|
|
*/
|
|
|
- public TbBusiness findByChinaCarNo(String carNo,int inOrOut) {
|
|
|
+ public TbBusiness findByChinaCarNo(String carNo, int inOrOut) {
|
|
|
QueryWrapper<TbBusiness> ew = new QueryWrapper<>();
|
|
|
ew.eq("china_car_no", carNo);
|
|
|
- if (inOrOut==1){
|
|
|
- ew.eq("admin_confirm_in",0).isNull("china_car_in_channel");
|
|
|
- }else {
|
|
|
- ew.eq("admin_confirm_out",0)
|
|
|
+ if (inOrOut == 1) {
|
|
|
+ ew.eq("admin_confirm_in", 0).isNull("china_car_in_channel");
|
|
|
+ } else {
|
|
|
+ ew.eq("admin_confirm_out", 0)
|
|
|
.isNull("china_car_out_channel")
|
|
|
.isNotNull("china_car_in_time");
|
|
|
}
|
|
|
- return this.getOne(ew);
|
|
|
+ return this.getOne(ew);
|
|
|
}
|
|
|
|
|
|
|