/// <summary> /// 获得下游 /// </summary> /// <param name="sellerId"></param> /// <param name="dbId"></param> /// <returns></returns> public RelationMappingEntity GetDownOrder(int sellerId, int dbId, int orderId, int upBuyerId) { RelationMappingEntity relationMappingEntity = new RelationMappingEntity(); ConnectorRelation connectorEntity = new ConnectorBusiness().GetDownConnector(sellerId, upBuyerId, dbId); if (connectorEntity.Id == null) { return(relationMappingEntity); } relationMappingEntity.ConnectorMapping.Add(sellerId, Utils.ToInt(connectorEntity.SellerId)); relationMappingEntity.ConnectorEntity = connectorEntity; DataTable data = DBTable($"UpConnectorId={connectorEntity.ThirdConnectorId} and DownConnectorId={connectorEntity.Id} and UpOrderId={orderId}"); if (data == null || data.Rows.Count == 0) { return(relationMappingEntity); } foreach (DataRow dr in data.Rows) { OrderRelationEntity orderRelationEntity = new OrderRelationEntity(); orderRelationEntity.SetValues(dr); relationMappingEntity.OrderRelationEntity = orderRelationEntity; int upOrderId = Utils.ToInt(orderRelationEntity.UpOrderId); int downOrderId = Utils.ToInt(orderRelationEntity.DownOrderId); string upOddNumber = orderRelationEntity.UpOddNumber; string downOddNumber = orderRelationEntity.DownOddNumber; if (!relationMappingEntity.OrderMapping.ContainsKey(upOrderId)) { relationMappingEntity.OrderMapping.Add(upOrderId, downOrderId); } if (!relationMappingEntity.OrderOddNumberMapping.ContainsKey(upOddNumber)) { relationMappingEntity.OrderOddNumberMapping.Add(upOddNumber, downOddNumber); } new DispatchRelationBusiness().GetOrderDispatch(relationMappingEntity); } return(relationMappingEntity); }
public int Insert(int disPatchId, OrderRelationEntity orderRelationEntity, Dictionary <string, object> orderDic) { int downDisPatchId = orderDic.ToInt("DispatchId", 0); if (downDisPatchId == 0) { throw new Exception("代下单失败"); } DispatchRelationEntity dispatchRelationEntity = new DispatchRelationEntity() { UpDispatchId = disPatchId, OrderRelationId = orderRelationEntity.Id, DownDispatchId = downDisPatchId }; return(DbAccess.ExecuteUpsert(TableName, dispatchRelationEntity, new string[] { "UpDispatchId", "OrderRelationId", "DownDispatchId" })); }
/// <summary> /// 修改上游订单 /// </summary> /// <param name="ConnectorEntity"></param> /// <param name="orderDic"></param> /// <returns></returns> public int UpdateUpOrder(ConnectorRelation ConnectorEntity, Dictionary <string, object> orderDic) { int upOrderId = orderDic.ToInt("OrderId", 0); decimal upPayables = Utils.ToDecimal(orderDic.ToValue("Payables")); if (upOrderId == 0) { throw new Exception("代下单失败"); } OrderRelationEntity orderRelationEntity = new OrderRelationEntity() { UpConnectorId = ConnectorEntity.ThirdConnectorId, UpOrderId = upOrderId, UpPayables = upPayables, DownConnectorId = ConnectorEntity.Id, }; return(DbAccess.ExecuteUpdate(TableName, orderRelationEntity, new string[] { "UpConnectorId", "UpOrderId", "DownConnectorId" })); }
/// <summary> /// 插入订单关联信息 /// </summary> /// <param name="orderId"></param> /// <param name="oddNumber"></param> /// <param name="ConnectorEntity"></param> /// <param name="orderDic"></param> /// <returns></returns> public int Insert(int orderId, string oddNumber, ConnectorRelation ConnectorEntity, Dictionary <string, object> orderDic) { int upOrderId = orderDic.ToInt("OrderId", 0); string upOddNumber = orderDic.ToValue("OddNumber"); if (upOrderId == 0) { throw new Exception("代下单失败"); } OrderRelationEntity orderRelationEntity = new OrderRelationEntity() { UpConnectorId = ConnectorEntity.Id, UpOrderId = upOrderId, UpOddNumber = upOddNumber, DownConnectorId = ConnectorEntity.ThirdConnectorId, DownOrderId = orderId, DownOddNumber = oddNumber }; return(DbAccess.ExecuteUpsert(TableName, orderRelationEntity, new string[] { "UpConnectorId", "UpOrderId", "DownConnectorId", "DownOrderId" })); }