|
@@ -8,6 +8,7 @@ import com.iotechn.unimall.core.exception.AdminServiceException;
|
|
import com.iotechn.unimall.core.exception.AppServiceException;
|
|
import com.iotechn.unimall.core.exception.AppServiceException;
|
|
import com.iotechn.unimall.core.exception.ExceptionDefinition;
|
|
import com.iotechn.unimall.core.exception.ExceptionDefinition;
|
|
import com.iotechn.unimall.core.exception.ServiceException;
|
|
import com.iotechn.unimall.core.exception.ServiceException;
|
|
|
|
+import com.iotechn.unimall.core.util.CalculationUtil;
|
|
import com.iotechn.unimall.core.util.GeneratorUtil;
|
|
import com.iotechn.unimall.core.util.GeneratorUtil;
|
|
import com.iotechn.unimall.data.domain.*;
|
|
import com.iotechn.unimall.data.domain.*;
|
|
import com.iotechn.unimall.data.dto.DynamicDTO;
|
|
import com.iotechn.unimall.data.dto.DynamicDTO;
|
|
@@ -64,6 +65,8 @@ public class TradeAppServiceImpl implements TradeAppService {
|
|
private GeTuiUtils geTuiUtils;
|
|
private GeTuiUtils geTuiUtils;
|
|
@Autowired
|
|
@Autowired
|
|
private PositionReportMapper positionReportMapper;
|
|
private PositionReportMapper positionReportMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ BuyReportMapper buyReportMapper;
|
|
|
|
|
|
WebSocket webSocket = new WebSocket();
|
|
WebSocket webSocket = new WebSocket();
|
|
|
|
|
|
@@ -312,6 +315,7 @@ public class TradeAppServiceImpl implements TradeAppService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public void confirm(String id) throws ServiceException, ParseException {
|
|
public void confirm(String id) throws ServiceException, ParseException {
|
|
TradeContractDO tradeContractDO = tradeContractMapper.selectById(id);
|
|
TradeContractDO tradeContractDO = tradeContractMapper.selectById(id);
|
|
Wrapper wrapper = new EntityWrapper();
|
|
Wrapper wrapper = new EntityWrapper();
|
|
@@ -324,22 +328,128 @@ public class TradeAppServiceImpl implements TradeAppService {
|
|
wrapper.eq("task_status", TaskStatusType.STATUS4.getCode());
|
|
wrapper.eq("task_status", TaskStatusType.STATUS4.getCode());
|
|
wrapper.eq("order_no", tradeDO.getOrderNo());
|
|
wrapper.eq("order_no", tradeDO.getOrderNo());
|
|
List<TaskDO> taskDOS = taskMapper.selectList(wrapper);
|
|
List<TaskDO> taskDOS = taskMapper.selectList(wrapper);
|
|
|
|
+ Date now = new Date();
|
|
if (taskDOS.size() > 0) {
|
|
if (taskDOS.size() > 0) {
|
|
TaskDO taskDO = taskDOS.get(0);
|
|
TaskDO taskDO = taskDOS.get(0);
|
|
taskDO.setIsConfirm(0);
|
|
taskDO.setIsConfirm(0);
|
|
- taskDO.setTaskStatus(TaskStatusType.STATUS1.getCode());
|
|
|
|
|
|
+ taskDO.setTaskStatus(TaskStatusType.STATUS2.getCode());
|
|
taskMapper.updateById(taskDO);
|
|
taskMapper.updateById(taskDO);
|
|
-
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("value", taskDO.getCarNo());
|
|
|
|
- map.put("valueOne", storeMapper.selectById(taskDO.getStoreId()).getName());
|
|
|
|
- map.put("page", "pages/user/task");
|
|
|
|
- map.put("templateId", "T6EwpfrZ9KkKjriCZVRqOYIJjQFYkoWwAGSalX9Ky_c");
|
|
|
|
- map.put("userId", taskDO.getUserId());
|
|
|
|
- map.put("header", "您好,客户已确定可完成入库任务!");
|
|
|
|
- map.put("remark", "点击进入小程序完成任务");
|
|
|
|
- sendUtils.sendMessageForDeliver(map);
|
|
|
|
- geTuiUtils.pushByCid("客户确认提醒","客户已确认可以卸货,请及时完成入库任务",taskDO.getUserId());
|
|
|
|
|
|
+ BuyDO buyDO = buyMapper.selectById(tradeDO.getSalebuyId());
|
|
|
|
+ if (buyDO != null) {
|
|
|
|
+ StoreDO storeDO = storeMapper.selectById(buyDO.getStoreId());
|
|
|
|
+ storeDO.setInventory(storeDO.getInventory()+taskDO.getNetWeight());
|
|
|
|
+ storeMapper.updateById(storeDO);
|
|
|
|
+ }
|
|
|
|
+ // 查询公司负责人姓名
|
|
|
|
+ CompanyDO companyDO = companyMapper.selectById(tradeDO.getTradeCompanyId());
|
|
|
|
+ BuyReportDO buyReportDO = reportMapper.getTradeBuyContract(taskDO.getId());
|
|
|
|
+ buyReportDO.setSellerName(companyDO.getPersonName());
|
|
|
|
+ buyReportDO.setGmtUpdate(now);
|
|
|
|
+ buyReportDO.setGmtCreate(now);
|
|
|
|
+ buyReportDO.setUserId(taskDO.getUserId());
|
|
|
|
+ if(buyReportDO.getCount() <0){
|
|
|
|
+ BuyReportDO buyReportDOTurn = new BuyReportDO();
|
|
|
|
+ buyReportDO.setCompanyId(tradeDO.getCompanyId());
|
|
|
|
+ BeanUtils.copyProperties(buyReportDO,buyReportDOTurn);
|
|
|
|
+ buyReportDOTurn.setCount(0f);
|
|
|
|
+ buyReportDOTurn.setGmtCreate(now);
|
|
|
|
+ buyReportDOTurn.setGmtUpdate(now);
|
|
|
|
+ buyReportDOTurn.setReplen(CalculationUtil.subToFloat(0,buyReportDO.getCount()));
|
|
|
|
+ buyReportDOTurn.setNetWeight(CalculationUtil.subToFloat(0,buyReportDO.getCount()));
|
|
|
|
+
|
|
|
|
+ //已结束计算仓储费情况
|
|
|
|
+ if(buyReportDO.getStorageFee() > 0){
|
|
|
|
+ buyReportDOTurn.setStorageFee(CalculationUtil.mulToFloat(CalculationUtil.div(buyReportDO.getStorageFee(),buyReportDO.getNetWeight()),buyReportDOTurn.getNetWeight()));
|
|
|
|
+ buyReportDO.setStorageFee(buyReportDO.getStorageFee() - buyReportDOTurn.getStorageFee());
|
|
|
|
+ buyReportDO.setNetWeight(CalculationUtil.addToFloat(buyReportDO.getNetWeight(),buyReportDO.getCount()));
|
|
|
|
+ buyReportDO.setMoney(CalculationUtil.mulToFloat(CalculationUtil.div(buyReportDO.getMoney(),buyReportDO.getNetWeight()),CalculationUtil.addToFloat(buyReportDO.getNetWeight(),buyReportDO.getCount())));
|
|
|
|
+ buyReportDO.setNotMoney(CalculationUtil.mulToFloat(CalculationUtil.div(buyReportDO.getNotMoney(),buyReportDO.getNetWeight()),CalculationUtil.addToFloat(buyReportDO.getNetWeight(),buyReportDO.getCount())));
|
|
|
|
+ buyReportDOTurn.setCount(0f);
|
|
|
|
+ buyReportDOTurn.setGmtCreate(now);
|
|
|
|
+ buyReportDOTurn.setGmtUpdate(now);
|
|
|
|
+ buyReportDOTurn.setReplen(CalculationUtil.subToFloat(0,buyReportDO.getCount()));
|
|
|
|
+ buyReportDOTurn.setNetWeight(CalculationUtil.subToFloat(0,buyReportDO.getCount()));
|
|
|
|
+ buyReportDOTurn.setUnitPrice1(0f);
|
|
|
|
+ buyReportDOTurn.setMoney(0f);
|
|
|
|
+ buyReportDOTurn.setNotMoney(0f);
|
|
|
|
+ buyReportDO.setCount(0f);
|
|
|
|
+ buyReportMapper.insert(buyReportDO);
|
|
|
|
+ buyReportMapper.insert(buyReportDOTurn);
|
|
|
|
+ }
|
|
|
|
+ //未结束计算仓储费情况
|
|
|
|
+ else{
|
|
|
|
+ wrapper = new EntityWrapper();
|
|
|
|
+ wrapper.eq("order_no",tradeDO.getOrderNo());
|
|
|
|
+ wrapper.eq("task_status",TaskStatusType.STATUS2.getCode());
|
|
|
|
+ wrapper.eq("task_type","入库任务");
|
|
|
|
+ wrapper.eq("car_no",buyReportDO.getCarNo());
|
|
|
|
+ taskDOS = taskMapper.selectList(wrapper);
|
|
|
|
+ if(taskDOS.size() > 0){
|
|
|
|
+ taskDO = taskDOS.get(0);
|
|
|
|
+ TaskDO taskTurn = new TaskDO();
|
|
|
|
+ BeanUtils.copyProperties(taskDO,taskTurn);
|
|
|
|
+ taskDO.setNetWeight(CalculationUtil.addToFloat(taskDO.getNetWeight(),buyReportDO.getCount()));
|
|
|
|
+ taskDO.setGrossWeight(CalculationUtil.addToFloat(taskDO.getNetWeight(),taskDO.getSkinWeight()));
|
|
|
|
+ taskTurn.setNetWeight(buyReportDOTurn.getNetWeight());
|
|
|
|
+ taskTurn.setGrossWeight(CalculationUtil.addToFloat(taskTurn.getNetWeight(),taskTurn.getSkinWeight()));
|
|
|
|
+ taskTurn.setGmtUpdate(now);
|
|
|
|
+ buyReportDO.setNetWeight(CalculationUtil.addToFloat(buyReportDO.getNetWeight(),buyReportDO.getCount()));
|
|
|
|
+// buyReportDO.setMoney(CalculationUtil.mulToFloat(CalculationUtil.div(buyReportDO.getMoney(),buyReportDO.getNetWeight()),CalculationUtil.addToFloat(buyReportDO.getNetWeight(),buyReportDO.getCount())));
|
|
|
|
+// buyReportDO.setNotMoney(CalculationUtil.mulToFloat(CalculationUtil.div(buyReportDO.getNotMoney(),buyReportDO.getNetWeight()),CalculationUtil.addToFloat(buyReportDO.getNetWeight(),buyReportDO.getCount())));
|
|
|
|
+ buyReportDO.setMoney(CalculationUtil.mulToFloat(buyReportDO.getNetWeight(),buyReportDO.getUnitPrice1()));
|
|
|
|
+ buyReportDO.setNotMoney(CalculationUtil.mulToFloat(buyReportDO.getNetWeight(),buyReportDO.getUnitPrice1()));
|
|
|
|
+ buyReportDOTurn.setCount(0f);
|
|
|
|
+ buyReportDOTurn.setGmtCreate(now);
|
|
|
|
+ buyReportDOTurn.setGmtUpdate(now);
|
|
|
|
+ buyReportDOTurn.setReplen(CalculationUtil.subToFloat(0,buyReportDO.getCount()));
|
|
|
|
+ buyReportDOTurn.setNetWeight(CalculationUtil.subToFloat(0,buyReportDO.getCount()));
|
|
|
|
+ buyReportDOTurn.setUnitPrice1(0f);
|
|
|
|
+ buyReportDOTurn.setMoney(0f);
|
|
|
|
+ buyReportDOTurn.setNotMoney(0f);
|
|
|
|
+ buyReportDO.setCount(0f);
|
|
|
|
+ buyReportMapper.insert(buyReportDO);
|
|
|
|
+ buyReportMapper.insert(buyReportDOTurn);
|
|
|
|
+ taskDO.setReportId(buyReportDO.getId());
|
|
|
|
+ taskTurn.setReportId(buyReportDOTurn.getId());
|
|
|
|
+ taskMapper.updateById(taskDO);
|
|
|
|
+ taskMapper.insert(taskTurn);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ throw new AdminServiceException(ExceptionDefinition.ADMIN_UNKNOWN_EXCEPTION);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ buyReportDO.setGmtCreate(now);
|
|
|
|
+ buyReportDO.setGmtUpdate(now);
|
|
|
|
+ buyReportDO.setUserId(taskDO.getUserId());
|
|
|
|
+ buyReportDO.setCompanyId(taskDO.getCompanyId());
|
|
|
|
+ if(buyReportMapper.insert(buyReportDO) <= 0){
|
|
|
|
+ throw new AppServiceException(ExceptionDefinition.APP_UNKNOWN_EXCEPTION);
|
|
|
|
+ }
|
|
|
|
+ taskDO.setReportId(buyReportDO.getId());
|
|
|
|
+ taskMapper.updateById(taskDO);
|
|
|
|
+ }
|
|
|
|
+ MessageDO messageDO = new MessageDO();
|
|
|
|
+ messageDO.setCustomer("客户");
|
|
|
|
+ messageDO.setOperation(" 已确认"+buyReportDO.getCarNo()+"车辆卸货,");
|
|
|
|
+ messageDO.setResult("请及时申请付款");
|
|
|
|
+ messageDO.setGmtUpdate(now);
|
|
|
|
+ messageDO.setGmtCreate(now);
|
|
|
|
+ messageDO.setCompanyId(buyReportDO.getCompanyId());
|
|
|
|
+ messageDO.setPath("/report/tradeTotal");
|
|
|
|
+ messageMapper.insert(messageDO);
|
|
|
|
+ webSocket.sendMessageByRole(messageDO, "内勤", buyReportDO.getCompanyId());
|
|
|
|
+// Map<String, Object> map = new HashMap<>();
|
|
|
|
+// map.put("value", taskDO.getCarNo());
|
|
|
|
+// map.put("valueOne", storeMapper.selectById(taskDO.getStoreId()).getName());
|
|
|
|
+// map.put("page", "pages/user/task");
|
|
|
|
+// map.put("templateId", "T6EwpfrZ9KkKjriCZVRqOYIJjQFYkoWwAGSalX9Ky_c");
|
|
|
|
+// map.put("userId", taskDO.getUserId());
|
|
|
|
+// map.put("header", "您好,客户已确定可完成入库任务!");
|
|
|
|
+// map.put("remark", "点击进入小程序完成任务");
|
|
|
|
+// sendUtils.sendMessageForDeliver(map);
|
|
|
|
+// geTuiUtils.pushByCid("客户确认提醒","客户已确认可以卸货,请及时完成入库任务",taskDO.getUserId());
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|