|
|
@@ -33,6 +33,7 @@ import com.goafanti.common.model.TOrder;
|
|
|
import com.goafanti.common.model.TOrderBill;
|
|
|
import com.goafanti.common.model.TOrderDetail;
|
|
|
import com.goafanti.common.model.User;
|
|
|
+import com.goafanti.common.utils.BeanUtilsExt;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
import com.goafanti.core.mybatis.JDBCIdGenerator;
|
|
|
@@ -172,18 +173,24 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
* @param actionType
|
|
|
*/
|
|
|
public void setOrderState(OrderAction orderAction,BigDecimal changeAmount,TOrder tOrder,boolean confrim){
|
|
|
+ BigDecimal initial = new BigDecimal(0);
|
|
|
checkOrder(tOrder);
|
|
|
if(orderAction == OrderAction.ADD_INTENTION){ //添加意向订单
|
|
|
- tOrder.setOrderStatus(OrderState.INVALID.getCode());
|
|
|
+ tOrder.setOrderStatus(OrderState.WAIT_FOR_CONFIRM.getCode());
|
|
|
tOrder.setLiquidationStatus(LiquidationState.WAIT_PAY_FIRST_BALANCE.getCode());
|
|
|
tOrder.setOrderStage(OrderStage.INTENTION.getCode());
|
|
|
tOrder.setProjectStage(ProjectStage.NOT_SATISFY_CONDITION.getCode());
|
|
|
- tOrder.setActuallyFirstPayment(new BigDecimal(0));
|
|
|
- tOrder.setActuallyTotalAmount(new BigDecimal(0));
|
|
|
- tOrder.setActuallyBrokerageAmount(new BigDecimal(0));
|
|
|
- tOrder.setActuallyWithdrawAmount(new BigDecimal(0));
|
|
|
+ tOrder.setLiquidationStatus(LiquidationState.WAIT_PAY_FIRST_BALANCE.getCode());
|
|
|
+ tOrder.setSignFirstPayment(initial);
|
|
|
+ tOrder.setActuallyFirstPayment(initial);
|
|
|
+ tOrder.setSignBrokerageAmount(initial);
|
|
|
+ tOrder.setActuallyBrokerageAmount(initial);
|
|
|
+ tOrder.setSignTotalAmount(initial);
|
|
|
+ tOrder.setActuallyTotalAmount(initial);
|
|
|
+ tOrder.setSignWithdrawAmount(initial);
|
|
|
+ tOrder.setActuallyWithdrawAmount(initial);
|
|
|
}else if(orderAction == OrderAction.CONFIRM_INTENTION){ //确认意向订单 (用户确认)
|
|
|
- if(tOrder.getOrderStatus() == OrderState.WAIT_FOR_CONFIRM.getCode()){
|
|
|
+ if(tOrder.getOrderStatus() != OrderState.WAIT_FOR_CONFIRM.getCode()){
|
|
|
throw new BusinessException(new Error(ErrorConstants.NOT_ACCORD_WITH_NEXT,"确认意向订单"));
|
|
|
}
|
|
|
if (confrim) {
|
|
|
@@ -378,10 +385,9 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
}
|
|
|
boolean flag = true;
|
|
|
if(tOrder.getOrderStatus() != OrderState.WAIT_FOR_CONFIRM.getCode()
|
|
|
- || tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode()){
|
|
|
+ && tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode()){
|
|
|
flag = false;
|
|
|
}
|
|
|
-
|
|
|
if(tOrder.getLiquidationStatus() != LiquidationState.WAIT_PAY_FIRST_BALANCE.getCode()
|
|
|
&& tOrder.getLiquidationStatus() != LiquidationState.WAIT_PAY_LAST_BALANCE.getCode()
|
|
|
&& tOrder.getLiquidationStatus() != LiquidationState.ALREADY_PAY.getCode()){
|
|
|
@@ -424,11 +430,9 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
active.setRefuseIntention(false);
|
|
|
}
|
|
|
boolean flag = true;
|
|
|
- if(tOrder.getOrderStatus() != OrderState.WAIT_FOR_CONFIRM.getCode()
|
|
|
- || tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode()){
|
|
|
+ if(tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode()){
|
|
|
flag = false;
|
|
|
}
|
|
|
-
|
|
|
if(tOrder.getLiquidationStatus() != LiquidationState.WAIT_PAY_FIRST_BALANCE.getCode()
|
|
|
&& tOrder.getLiquidationStatus() != LiquidationState.WAIT_PAY_LAST_BALANCE.getCode()
|
|
|
&& tOrder.getLiquidationStatus() != LiquidationState.ALREADY_PAY.getCode()){
|
|
|
@@ -480,10 +484,8 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
active.setConfirmIntention(false);
|
|
|
active.setRefuseIntention(false);
|
|
|
}
|
|
|
- // 平台方作为中间方 确认首付 - 尾款 - 退款
|
|
|
boolean flag = true;
|
|
|
- if(tOrder.getOrderStatus() != OrderState.WAIT_FOR_CONFIRM.getCode()
|
|
|
- || tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode()){
|
|
|
+ if(tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode()){
|
|
|
flag = false;
|
|
|
}
|
|
|
if(tOrder.getLiquidationStatus() != LiquidationState.WAIT_PAY_FIRST_BALANCE.getCode()
|
|
|
@@ -552,9 +554,6 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
flag = true;
|
|
|
if(tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode())
|
|
|
flag = false;
|
|
|
- if(tOrder.getLiquidationStatus() != LiquidationState.WAIT_PAY_LAST_BALANCE.getCode()
|
|
|
- && tOrder.getApproval() != ApprovalState.AUDIT_PASS.getCode())
|
|
|
- flag = false;
|
|
|
active.setApplySign(flag);
|
|
|
return active;
|
|
|
}
|
|
|
@@ -772,7 +771,8 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
public Pagination<OrderListBo> selectServiceOrder(OrderListBo bo,String startDate,String endDate,Integer intention,Integer formal,
|
|
|
Integer pageNo, Integer pageSize) {
|
|
|
Map<String,Object> params = disposeParams(bo,startDate,endDate);
|
|
|
- params.put("salesmanId", TokenManager.getAdminId());
|
|
|
+ if(!TokenManager.hasRole(AFTConstants.SUPERADMIN))
|
|
|
+ params.put("salesmanId", TokenManager.getAdminId());
|
|
|
if((1 == intention && 0 == formal) || ( 0 == intention && 1 == formal)){
|
|
|
params.put("intention", intention);
|
|
|
params.put("formal", formal);
|
|
|
@@ -781,6 +781,19 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
}
|
|
|
Pagination<OrderListBo> data = (Pagination<OrderListBo>)findPage("selectServiceOrderByPage","selectServiceOrderCount",
|
|
|
params, pageNo, pageSize);
|
|
|
+ TOrder tOrder = null;
|
|
|
+ List<OrderListBo> list = (List<OrderListBo>)data.getList();
|
|
|
+ for(OrderListBo olb:list){
|
|
|
+ tOrder = new TOrder();
|
|
|
+ try {
|
|
|
+ BeanUtilsExt.copyProperties(tOrder, olb);
|
|
|
+ tOrder.setActuallyTotalAmount(new BigDecimal(olb.getActuallyTotalAmount()));
|
|
|
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ olb.setActive(setOperatorActive(tOrder));
|
|
|
+ }
|
|
|
+ data.setList(list);
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
@@ -799,28 +812,31 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
|
|
|
@Override
|
|
|
public ServiceOrderDetailBo selectServiceOrderDetail(String orderNo) {
|
|
|
+ ServiceOrderDetailBo bo = tOrderMapper.selectServiceOrderDetail(orderNo);
|
|
|
+ TOrder tOrder = new TOrder();
|
|
|
+ try {
|
|
|
+ BeanUtilsExt.copyProperties(tOrder, bo);
|
|
|
+ tOrder.setActuallyTotalAmount(new BigDecimal(bo.getActuallyTotalAmount()));
|
|
|
+ bo.setActive(setOperatorActive(tOrder));
|
|
|
+ } catch (IllegalAccessException | InvocationTargetException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
return tOrderMapper.selectServiceOrderDetail(orderNo);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int updateServiceOrder(String orderNo, String firstPayment, String orderAmount, String signFirstPayment,
|
|
|
- String signTotalAmount, String orderRemarks) {
|
|
|
+ public int updateServiceOrder(String orderNo, String signFirstPayment,
|
|
|
+ String signTotalAmount, String orderRemarks) {
|
|
|
TOrder tOrder = tOrderMapper.selectByPrimaryKey(orderNo);
|
|
|
checkOrder(tOrder);
|
|
|
boolean flag = false;
|
|
|
- if (new BigDecimal(firstPayment).compareTo(tOrder.getFirstPayment()) != 0)
|
|
|
- flag = true;
|
|
|
- if (new BigDecimal(orderAmount).compareTo(tOrder.getOrderAmount()) != 0)
|
|
|
- flag = true;
|
|
|
if (new BigDecimal(signFirstPayment).compareTo(tOrder.getSignFirstPayment()) != 0)
|
|
|
flag = true;
|
|
|
if (new BigDecimal(signTotalAmount).compareTo(tOrder.getSignTotalAmount()) != 0)
|
|
|
flag = true;
|
|
|
- if (tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode() || flag) {
|
|
|
+ if (tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode() && flag) {
|
|
|
throw new BusinessException(new Error(ErrorConstants.ORDER_CAN_NOT_MODIFY, orderNo, ""));
|
|
|
}
|
|
|
- tOrder.setFirstPayment(new BigDecimal(firstPayment));
|
|
|
- tOrder.setOrderAmount(new BigDecimal(orderAmount));
|
|
|
tOrder.setSignFirstPayment(new BigDecimal(signFirstPayment));
|
|
|
tOrder.setSignTotalAmount(new BigDecimal(signTotalAmount));
|
|
|
tOrder.setOrderRemarks(orderRemarks);
|
|
|
@@ -830,8 +846,8 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int updateSignServiceOrder(String orderNo, String signFirstPayment, String signTotalAmount,String approval,
|
|
|
- String orderRemarks) {
|
|
|
+ public int updateSignServiceOrder(String orderNo, String signFirstPayment, String signTotalAmount,
|
|
|
+ String approval,String orderRemarks) {
|
|
|
TOrder tOrder = tOrderMapper.selectByPrimaryKey(orderNo);
|
|
|
checkOrder(tOrder);
|
|
|
if (tOrder.getOrderStatus() != OrderState.WAIT_FOR_SIGN.getCode()) {
|
|
|
@@ -891,6 +907,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
detail.setId(UUID.randomUUID().toString());
|
|
|
detail.setOrderNo(orderNo);
|
|
|
detail.setCommodityId(commodityId);
|
|
|
+ detail.setCommodityName(commodityName);
|
|
|
detail.setCommodityQuantity(commodityQuantity);
|
|
|
detail.setCommodityType(commodityType);
|
|
|
detail.setCommodityMode(StringUtils.isBlank(commodityMode)?DEFAULT_COMMODITY_MODE:commodityMode);
|
|
|
@@ -898,7 +915,8 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
detail.setDiscountPrice(new BigDecimal(discountPrice));
|
|
|
detail.setCommodityFirstPayment(new BigDecimal(commodityFirstPayment));
|
|
|
detail.setDiscountFirstPayment(new BigDecimal(discountFirstPayment));
|
|
|
- detail.setRemarks(remarks);
|
|
|
+ detail.setRemarks(remarks);
|
|
|
+ detail.setCreateTime(new Date());
|
|
|
tOrderDetailMapper.insert(detail);
|
|
|
//订单市场价总额
|
|
|
BigDecimal totalAmountChange = new BigDecimal(commodityPrice).multiply(new BigDecimal(commodityQuantity));
|
|
|
@@ -993,7 +1011,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<OrganizationManagement> selectMyDaeps(){
|
|
|
+ public List<OrganizationManagement> selectMyDeps(){
|
|
|
if(TokenManager.hasRole(AFTConstants.SUPERADMIN) || TokenManager.hasRole(AFTConstants.APPROVAL_DECISION))
|
|
|
return organizationManagementMapper.selectAllDeps();
|
|
|
else
|
|
|
@@ -1005,7 +1023,7 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
String superIds = "";
|
|
|
for(OrganizationManagement om : superData){
|
|
|
if(!om.getId().equals(om.getSuperId())){
|
|
|
- superIds += om.getSuperId() + ",";
|
|
|
+ superIds += om.getId() + ",";
|
|
|
}
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(superIds)) subData = organizationManagementMapper.selectSubDeps(superIds.substring(0, superIds.length()-1));
|
|
|
@@ -1032,7 +1050,12 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
Integer intention, Integer formal, String depIds,Integer pageNo, Integer pageSize) {
|
|
|
Map<String,Object> params = disposeParams(bo,startDate,endDate);
|
|
|
if(StringUtils.isNotBlank(depIds)) {
|
|
|
- params.put("depIds", depIds);
|
|
|
+ if(!TokenManager.hasRole(AFTConstants.SUPERADMIN) && !TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)){
|
|
|
+ params.put("depIds","'" + depIds.replace(",", "','") + "'");
|
|
|
+ }else{
|
|
|
+ if(!depIds.contains(",")) params.put("depIds","'" + depIds + "'");
|
|
|
+ }
|
|
|
+
|
|
|
}else{
|
|
|
if(!TokenManager.hasRole(AFTConstants.SUPERADMIN) && !TokenManager.hasRole(AFTConstants.APPROVAL_DECISION))
|
|
|
return new Pagination<OrderListBo>();
|
|
|
@@ -1043,8 +1066,22 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
}else if(0 == intention && 0 == formal){
|
|
|
return new Pagination<OrderListBo>();
|
|
|
}
|
|
|
- return (Pagination<OrderListBo>)findPage("selectServiceOrderByPage","selectServiceOrderCount",
|
|
|
+ Pagination<OrderListBo> data = (Pagination<OrderListBo>)findPage("selectServiceOrderByPage","selectServiceOrderCount",
|
|
|
params, pageNo, pageSize);
|
|
|
+ TOrder tOrder = null;
|
|
|
+ List<OrderListBo> list = (List<OrderListBo>)data.getList();
|
|
|
+ for(OrderListBo olb:list){
|
|
|
+ tOrder = new TOrder();
|
|
|
+ try {
|
|
|
+ BeanUtilsExt.copyProperties(tOrder, olb);
|
|
|
+ tOrder.setActuallyTotalAmount(new BigDecimal(olb.getActuallyTotalAmount()));
|
|
|
+ } catch (InvocationTargetException | IllegalAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ olb.setActive(setOperatorActive(tOrder));
|
|
|
+ }
|
|
|
+ data.setList(list);
|
|
|
+ return data;
|
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@@ -1067,18 +1104,22 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
|
|
|
@Override
|
|
|
public int createServiceOrder(String uid, Integer orderType) {
|
|
|
+ BigDecimal initial = new BigDecimal(0);
|
|
|
TOrder tOrder = new TOrder();
|
|
|
+ tOrder.setOrderType(orderType);
|
|
|
tOrder.setOrderNo(idGenerator.generateId().toString());
|
|
|
tOrder.setCreater(TokenManager.getAdminId());
|
|
|
tOrder.setCreateTime(new Date());
|
|
|
tOrder.setBuyerId(uid);
|
|
|
tOrder.setSellerId(DEFAULT_PLATFORM_ID);
|
|
|
- tOrder.setBrokerageAmount(new BigDecimal(0));
|
|
|
- tOrder.setFirstPayment(new BigDecimal(0));
|
|
|
- tOrder.setOrderAmount(new BigDecimal(0));
|
|
|
+ tOrder.setSalesmanId(TokenManager.getAdminId());
|
|
|
+ tOrder.setBrokerageAmount(initial);
|
|
|
+ tOrder.setFirstPayment(initial);
|
|
|
+ tOrder.setOrderAmount(initial);
|
|
|
+ tOrder.setOrderChannel(OrderChannel.PORTAL.getCode());
|
|
|
tOrder.setOrderRemarks("");
|
|
|
tOrder.setDeleteSign(ActiveState.NORMAL.getCode());
|
|
|
- tOrder.setOrderChannel(OrderChannel.PORTAL.getCode());
|
|
|
+ tOrder.setApproval(ApprovalState.NORMAL.getCode());
|
|
|
setOrderState(OrderAction.ADD_INTENTION, new BigDecimal(0), tOrder, false);
|
|
|
return tOrderMapper.insert(tOrder);
|
|
|
}
|
|
|
@@ -1319,4 +1360,9 @@ public class OrderServiceImpl extends BaseMybatisDao<TOrderMapper> implements Or
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<TOrderDetail> selectOrderCommodity(String orderNo) {
|
|
|
+ return tOrderMapper.selectOrderCommodity(orderNo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|