|
|
@@ -4,6 +4,7 @@ import java.lang.reflect.InvocationTargetException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
@@ -19,7 +20,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import com.goafanti.common.bo.Error;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
+import com.goafanti.common.dao.AdminMapper;
|
|
|
import com.goafanti.common.dao.ContractMapper;
|
|
|
+import com.goafanti.common.dao.NoticeMapper;
|
|
|
import com.goafanti.common.dao.OrganizationManagementMapper;
|
|
|
import com.goafanti.common.dao.TOrderBillMapper;
|
|
|
import com.goafanti.common.dao.TOrderChangeMapper;
|
|
|
@@ -28,10 +31,13 @@ import com.goafanti.common.dao.TOrderMapper;
|
|
|
import com.goafanti.common.dao.TmpTableMapper;
|
|
|
import com.goafanti.common.dao.UserMapper;
|
|
|
import com.goafanti.common.enums.DeleteStatus;
|
|
|
+import com.goafanti.common.enums.NoticeReadStatus;
|
|
|
+import com.goafanti.common.enums.NoticeStatus;
|
|
|
import com.goafanti.common.error.BusinessException;
|
|
|
import com.goafanti.common.model.Admin;
|
|
|
import com.goafanti.common.model.Contract;
|
|
|
import com.goafanti.common.model.ContractTask;
|
|
|
+import com.goafanti.common.model.Notice;
|
|
|
import com.goafanti.common.model.OrganizationManagement;
|
|
|
import com.goafanti.common.model.TOrder;
|
|
|
import com.goafanti.common.model.TOrderBill;
|
|
|
@@ -92,7 +98,10 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
private TOrderChangeMapper tOrderChangeMapper;
|
|
|
@Autowired
|
|
|
private TmpTableMapper tmpTableMapper;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private AdminMapper adminMapper;
|
|
|
+ @Autowired
|
|
|
+ private NoticeMapper noticeMapper;
|
|
|
private final BigDecimal DEFAULT_FIRST_PAYMENT = new BigDecimal(0);//默认首付价格
|
|
|
private final BigDecimal DEFAULT_COMMODITY_PRICE = new BigDecimal(0);//默认单价
|
|
|
private final String DEFAULT_PLATFORM_ID = "0"; //平台默认id
|
|
|
@@ -367,7 +376,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
}else if(boundary == 1){
|
|
|
tOrder.setLiquidationStatus(LiquidationState.AGREE_REFUND.getCode()); //需要再退款
|
|
|
}else if(boundary == -1){
|
|
|
- throw new BusinessException(new Error(ErrorConstants.REFUND_BEYOND_SIGN,"退款"));
|
|
|
+ throw new BusinessException(new Error(ErrorConstants.REFUND_BEYOND_SIGN,"退款")); //超过退款金额
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1607,7 +1616,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
setOrderState(OrderAction.CONFIRM_REFUND, new BigDecimal(0), tOrder, confirm);
|
|
|
tOrder.setUpdateTime(new Date());
|
|
|
if(confirm){ //同意退款生成退款流水
|
|
|
- BigDecimal transactionAmount = tOrder.getActuallyTotalAmount().subtract(tOrder.getActuallyBrokerageAmount());
|
|
|
+ BigDecimal transactionAmount = tOrder.getActuallyTotalAmount().subtract(tOrder.getActuallyBrokerageAmount()).multiply(new BigDecimal(-1));
|
|
|
addFundRecord(orderNo, "平台方", DEFAULT_PLATFORM_ID,TokenManager.getUserId(), "同意退款系统生成流水",
|
|
|
TransactionSubject.REFUND, PayChannel.UNIONPAY,transactionAmount,TransactionMode.OFFLINE, AuditState.WAIT_AUDIT);
|
|
|
}
|
|
|
@@ -1704,6 +1713,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
change.setDeleteSign(DeleteStatus.UNDELETE.getCode());
|
|
|
tOrderChangeMapper.insert(change);
|
|
|
tOrderMapper.updateByPrimaryKeySelective(tOrder);
|
|
|
+ generatorNoticeData(NoticeStatus.ORDER_CHANGE_ADD,changeComment,tOrder);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
@@ -1746,6 +1756,8 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
if(StringUtils.isNotBlank(changeComment))change.setChangeComment(changeComment);
|
|
|
change.setChangeStatus(changeStatus);
|
|
|
tOrderChangeMapper.updateByPrimaryKeySelective(change);
|
|
|
+ TOrder tOrder = tOrderMapper.selectByPrimaryKey(change.getOrderNo());
|
|
|
+ generatorNoticeData(NoticeStatus.ORDER_CHANGE_ADD,changeComment,tOrder);
|
|
|
return updateOrderSatusByChange(change.getOrderNo());
|
|
|
}
|
|
|
|
|
|
@@ -1764,4 +1776,35 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
+
|
|
|
+ private void generatorNoticeData(NoticeStatus noticeType,String noticeComment,TOrder tOrder){
|
|
|
+ if(tOrder == null) return;
|
|
|
+ Notice notice = null;
|
|
|
+ List<Notice> noticeList = new ArrayList<>();
|
|
|
+ Calendar now = Calendar.getInstance();
|
|
|
+ now.set(Calendar.MILLISECOND, 0);
|
|
|
+ List<String> targetIds = new ArrayList<String>();
|
|
|
+ if(!tOrder.getSalesmanId().equals("") && !targetIds.contains(tOrder.getSalesmanId()))
|
|
|
+ targetIds.add(tOrder.getSalesmanId());
|
|
|
+ if(!tOrder.getFinanceId().endsWith("") && !targetIds.contains(tOrder.getFinanceId()))
|
|
|
+ targetIds.add(tOrder.getFinanceId());
|
|
|
+ if(!tOrder.getTechnicianId().equals("") && !targetIds.contains(tOrder.getTechnicianId()))
|
|
|
+ targetIds.add(tOrder.getTechnicianId());
|
|
|
+ Admin admin = adminMapper.selectAdminByRoleId(AFTConstants.TECH_ADMIN);
|
|
|
+ if(admin!= null && !targetIds.contains(admin.getId())) targetIds.add(admin.getId());
|
|
|
+ if(targetIds.size()>0){
|
|
|
+ for(String id: targetIds){
|
|
|
+ notice = new Notice();
|
|
|
+ notice.setId(UUID.randomUUID().toString());
|
|
|
+ notice.setCreateTime(now.getTime());
|
|
|
+ notice.setReaded(NoticeReadStatus.UNREAD.getCode());
|
|
|
+ notice.setRid(tOrder.getOrderNo());
|
|
|
+ notice.setNoticeType(noticeType.getCode());
|
|
|
+ notice.setContent(noticeType.getDesc() + ": 订单编号-" + tOrder.getOrderNo() + ",操作人-" + TokenManager.getAdminToken().getName());
|
|
|
+ noticeList.add(notice);
|
|
|
+ }
|
|
|
+ noticeMapper.insertBatch(noticeList);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|